Welcome! Log In Create A New Profile

Advanced

Walkthrough 3 - Code for the forum

Posted by kreason_77840070 
Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
Walkthrough 3 - Code for the forum
March 14, 2013 12:37PM
Did anyone else get errors with forumTest.php ?
Mine shows:
Notice: Undefined offset: 3 in D:\EasyPHP-5.3.3\www\forum\forumTest.php on line 123
Notice: Undefined offset: 3 in D:\EasyPHP-5.3.3\www\forum\forumTest.php on line 124

Language: PHP
122 print $tdStart . $secIDs[$i] . $tdEnd; 123 print $tdStart . $numPosts[$i] . $tdEnd; 124 print $tdStart . $numReply[$i] . $tdEnd;

any ideas?

http://capetown-airport.co.za/
Re: Walkthrough 3 - Code for the forum
March 14, 2013 03:04PM
More info

Theres some problem here

Language: PHP
if ($db_found) {   for ($i = 1; $i < 6; $i++) {   //================================================== // GET THE NUMBER OF POSTS IN EACH FORUM SECTION //==================================================   $SQL = "SELECT * FROM " . $tblPosts[$i];   $result = mysql_query($SQL);   if ($result) {   $num_rows = mysql_num_rows($result);   //================================================== // PUT THE NUMBER OF POSTS INTO AN ARRAY //================================================== $numPosts[$i] = $num_rows;   } else { print "error table posts"."<BR>";

http://capetown-airport.co.za/
avatar
Mac
Re: Walkthrough 3 - Code for the forum
March 14, 2013 04:28PM
Sorry... running around. Will answer tomorrow.
Re: Walkthrough 3 - Code for the forum
March 21, 2013 10:51AM
Not i never experienced any problems, i am using xamp and not easy php
my code is
Language: PHP
if ($db_found) {   for ($i = 1; $i < 6; $i++) {   //================================================== // GET THE NUMBER OF POSTS IN EACH FORUM SECTION //==================================================   $SQL = "SELECT * FROM " . $tblPosts[$i];   $result = mysql_query($SQL);   if ($result) {   $num_rows = mysql_num_rows($result);   //================================================== // PUT THE NUMBER OF POSTS INTO AN ARRAY //================================================== $numPosts[$i] = $num_rows;   } else { print "error";   } }   //========================================================= // GET THE NUMBER OF REPLIES IN EACH FORUM SECTION //========================================================   for ($i = 1; $i < 6; $i++) { $SQL = "SELECT * FROM " . $tblReply[$i]; $result = mysql_query($SQL);   if ($result) {   $num_rows = mysql_num_rows($result);

I am still trying to find out what could happening to urs, otherwise my application ran ok

..&ru..
Re: Walkthrough 3 - Code for the forum
March 21, 2013 12:48PM
I'm not getting the "Notice: Undefined offset: 3 " in xamp but its printing error even though the code seems to be executing fine. strange

http://capetown-airport.co.za/
avatar Re: Walkthrough 3 - Code for the forum
March 21, 2013 11:47PM
I did not experience the error but I typed the example out so I might have typed something different.

____________________________________________Nazi Coder____________________________________________

I'm not antisocial, I'm just not user friendly

"It's not a bug; it's an undocumented feature!" ~ some unknown Microsoft developer
avatar
Mac
Re: Walkthrough 3 - Code for the forum
March 22, 2013 08:25AM
That code is for explanation purposes as such - they know there are 5 posts so they use 6 in the loop

Language: PHP
for ($i = 1; $i < 6; $i++) {

However, if there is not 5 posts but less, it means it will iterate once to many, leading to the offset error.

So one should get the number of rows and use that

Language: PHP
for ($i = 1; $i < $num_rows; $i++) {


I am just picking this up, have not run the code myself again. but in general terms that is why such an error is generated
avatar Re: Walkthrough 3 - Code for the forum
April 12, 2013 07:01AM
Hi all, took a while, but eventually managed to finish this walkthrough's Final Project last week. My biggest challenge was to get the SQL statement right with all the correct ' needed, phew. Maybe I spent too much time on this, but thought it may help me with portfolio.
Cheers
avatar
Mac
Re: Walkthrough 3 - Code for the forum
April 12, 2013 10:21AM
There is a difference between a back tick and a single quote you use in a SQL query.

a back tick as in `column_name` are used when you use a reserved word as a the column_name - Google for MYSQL reserved words. If you do not back tick it, then your query will never work. Else you do not even have to use backticks.
Re: Walkthrough 3 - Code for the forum
April 22, 2013 06:28PM
Hi guys,

I see everyone's on the project...nice work guys!

I'm just running through Work-through 3 and i see that most of the links on homeandlearn are not leading to the right places, rather they take me back to the same page. Did anyone encounter this challenge?

Cheers.

78026962 afojonny
avatar
Mac
Re: Walkthrough 3 - Code for the forum
April 23, 2013 09:03AM
Did you download the fixed HTML zip file from the course website?
Re: Walkthrough 3 - Code for the forum
April 23, 2013 09:25AM
Hi Mac,

No, i didnt. I am using the one from the sent CD.

78026962 afojonny
avatar
Mac
Re: Walkthrough 3 - Code for the forum
April 23, 2013 11:24AM
The CD one is incorrect - fixed in Zip file.
Re: Walkthrough 3 - Code for the forum
April 23, 2013 11:38AM
Thanks Mac, i'd sort that out.

Here's one more question for today (i hope...lol):

How can one change a db table from read only to editable mode? I have been battling the exercise on the 'forum table' page of homeandlearn but not winning.

Thanks in anticipation.

78026962 afojonny
avatar
Mac
Re: Walkthrough 3 - Code for the forum
April 23, 2013 04:43PM
In phpMyAdmin? Then the table is corrupt. Mark and repair - the function is there.
Re: Walkthrough 3 - Code for the forum
May 15, 2013 08:50AM
Dear Mac

im using files from the CD, and you mentioned about zip file should be download it from website? can you give me a link or how to get to that file please?
Thank you

Mohammed
avatar
Mac
Re: Walkthrough 3 - Code for the forum
May 15, 2013 09:32AM
Where you downloaded the tut letter... it is there.
Sorry, only registered users may post in this forum.

Click here to login