Pikachu2000 Posted December 12, 2010 Share Posted December 12, 2010 Great. Now let's see if the script actually runs without errors, then start adding other functionality. Link to comment https://forums.phpfreaks.com/topic/221355-syntex-error/page/2/#findComment-1146025 Share on other sites More sharing options...
Pikachu2000 Posted December 12, 2010 Share Posted December 12, 2010 echo "<li>{$page['menu_name']}</li>"; Link to comment https://forums.phpfreaks.com/topic/221355-syntex-error/page/2/#findComment-1146027 Share on other sites More sharing options...
MMDE Posted December 12, 2010 Share Posted December 12, 2010 aame error but now i got the error on line 23 now witch is echo "<li>$page['menu_name']</li>"; if $page got assigned on line 29, how do you expect to use it on line 23? or did you change the code? Link to comment https://forums.phpfreaks.com/topic/221355-syntex-error/page/2/#findComment-1146028 Share on other sites More sharing options...
puremagnum Posted December 12, 2010 Author Share Posted December 12, 2010 if $page got assigned on line 29, how do you expect to use it on line 23? or did you change the code? Â i forgot a re-added my notes to self.. took em back out and now its on line 23 again my fault Link to comment https://forums.phpfreaks.com/topic/221355-syntex-error/page/2/#findComment-1146032 Share on other sites More sharing options...
Pikachu2000 Posted December 12, 2010 Share Posted December 12, 2010 It would probably be best if you were to post the whole script at this point. Just remove any database passwords, etc. Link to comment https://forums.phpfreaks.com/topic/221355-syntex-error/page/2/#findComment-1146033 Share on other sites More sharing options...
puremagnum Posted December 12, 2010 Author Share Posted December 12, 2010 It would probably be best if you were to post the whole script at this point. Just remove any database passwords, etc. i was one step ahead of u <?php $subject_set = mysql_query("SELECT * FROM subjects",$connection ); if(!$subject_set) { die("DB query failed:" . mysql_error()); } while($subject = mysql_fetch_array($subject_set)) { echo "<li>{$page['menu_name']}</li>"; } $query="SELECT * FROM pages WHERE subject_id = $subject['id']"; echo $query; $page_set=mysql_query($query) or die( "<br>Query string: $query<br>Produced error: " . mysql_error() ); echo"<ul class=\"pages\">"; while($page= mysql_fetch_array($page_set)) { echo "<li>{$page["menu_name"]}</li>"; } if(mysql_num_rows($page_set)>0){ } echo "</ul>"; ?> thats what im currently working on Link to comment https://forums.phpfreaks.com/topic/221355-syntex-error/page/2/#findComment-1146034 Share on other sites More sharing options...
MMDE Posted December 12, 2010 Share Posted December 12, 2010 It would probably be best if you were to post the whole script at this point. Just remove any database passwords, etc. Still I think you are correct about what the exact problem is though. echo "<li>{$page['menu_name']}</li>"; arrays must have brackets when used in magic quotes. Link to comment https://forums.phpfreaks.com/topic/221355-syntex-error/page/2/#findComment-1146035 Share on other sites More sharing options...
puremagnum Posted December 12, 2010 Author Share Posted December 12, 2010 what u mean MMDE?? Link to comment https://forums.phpfreaks.com/topic/221355-syntex-error/page/2/#findComment-1146037 Share on other sites More sharing options...
MMDE Posted December 12, 2010 Share Posted December 12, 2010 You should have done as he said  <?php $subject_set = mysql_query('SELECT * FROM subjects',$connection); if(!$subject_set){ die('DB query failed:' . mysql_error()); } while($subject = mysql_fetch_array($subject_set)){ echo '<li>'.$page['menu_name'].'</li>'; } $query='SELECT * FROM pages WHERE subject_id = '.$subject['id']; echo $query; $page_set=mysql_query($query) or die( '<br>Query string: '.$query.'<br>Produced error: ' . mysql_error() ); echo '<ul class="pages">'; while($page= mysql_fetch_array($page_set)){ echo '<li>'.$page["menu_name"].'</li>'; } echo '</ul>'; ?> Link to comment https://forums.phpfreaks.com/topic/221355-syntex-error/page/2/#findComment-1146038 Share on other sites More sharing options...
puremagnum Posted December 12, 2010 Author Share Posted December 12, 2010 thx for the code... inserted it got this when loaded pg  Notice: Undefined variable: page in C:\wamp\www\widget_corp\content.php on line 24 # Notice: Undefined variable: page in C:\wamp\www\widget_corp\content.php on line 24 # Notice: Undefined variable: page in C:\wamp\www\widget_corp\content.php on line 24 # SELECT * FROM pages WHERE subject_id =Query string: SELECT * FROM pages WHERE subject_id = Produced error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1  y is this sooo flippen hard if im such a newb!!! lol Link to comment https://forums.phpfreaks.com/topic/221355-syntex-error/page/2/#findComment-1146040 Share on other sites More sharing options...
Pikachu2000 Posted December 12, 2010 Share Posted December 12, 2010 Added curly braces around {$subject['id']}, no more parse errors . . . Â <?php $subject_set = mysql_query("SELECT * FROM subjects",$connection ); if(!$subject_set) { die("DB query failed:" . mysql_error()); } while($subject = mysql_fetch_array($subject_set)) { echo "<li>{$page['menu_name']}</li>"; } $query="SELECT * FROM pages WHERE subject_id = {$subject['id']}"; echo $query; $page_set=mysql_query($query) or die( "<br>Query string: $query<br>Produced error: " . mysql_error() ); echo"<ul class=\"pages\">"; while($page= mysql_fetch_array($page_set)) { echo "<li>{$page["menu_name"]}</li>"; } if(mysql_num_rows($page_set)>0) { } echo "</ul>"; ?> Link to comment https://forums.phpfreaks.com/topic/221355-syntex-error/page/2/#findComment-1146041 Share on other sites More sharing options...
MMDE Posted December 12, 2010 Share Posted December 12, 2010 <?php $subject_set = mysql_query('SELECT * FROM subjects',$connection); if(!$subject_set){ die('DB query failed:' . mysql_error()); } while($subject = mysql_fetch_array($subject_set)){ echo '<li>'.$subject['menu_name'].'</li>'; $subjects[]=$subject; } $query='SELECT * FROM pages WHERE subject_id = '.$subjects[0]['id']; echo $query; $page_set=mysql_query($query) or die( '<br>Query string: '.$query.'<br>Produced error: ' . mysql_error() ); echo '<ul class="pages">'; while($page= mysql_fetch_array($page_set)){ echo '<li>'.$page["menu_name"].'</li>'; } echo '</ul>'; ?> Â $page was never assigned when you first used it in the first loop! (all I originally did was to edit your script to not use magic quotes, because they scare me.) Link to comment https://forums.phpfreaks.com/topic/221355-syntex-error/page/2/#findComment-1146042 Share on other sites More sharing options...
puremagnum Posted December 12, 2010 Author Share Posted December 12, 2010 ok good news the pg is loading finally!!! woot  but now i see  SELECT * FROM pages WHERE subject_id = 1  inside of my navigation box lol. so im guessing its reading that line as a string?? Link to comment https://forums.phpfreaks.com/topic/221355-syntex-error/page/2/#findComment-1146044 Share on other sites More sharing options...
MMDE Posted December 12, 2010 Share Posted December 12, 2010 read the script, and you will see that you echo the query at some point. we added this so that while you were trying to figure out what was wrong, you would see it. now it is just to remove it. I won't do it for you. Link to comment https://forums.phpfreaks.com/topic/221355-syntex-error/page/2/#findComment-1146045 Share on other sites More sharing options...
puremagnum Posted December 12, 2010 Author Share Posted December 12, 2010 ok i fixed thx u guys soooooo much ... i h8 this stupid video for this.... should i stop useing the video??. considering its teaching me old syntex??. Link to comment https://forums.phpfreaks.com/topic/221355-syntex-error/page/2/#findComment-1146046 Share on other sites More sharing options...
MMDE Posted December 12, 2010 Share Posted December 12, 2010 ok i fixed thanks u guys soooooo much ... i h8 this stupid video for this.... should i stop useing the video??. considering its teaching me old syntex??. old? =P I think you should keep on using it, but try to mess around with it after you've seen how stuff has been done by others. You learn far more from that. syntax* Link to comment https://forums.phpfreaks.com/topic/221355-syntex-error/page/2/#findComment-1146048 Share on other sites More sharing options...
Pikachu2000 Posted December 12, 2010 Share Posted December 12, 2010 It isn't necessarily teaching old syntax, but it isn't teaching what most would consider best practices. Unfortunately, anyone can make a video, or write a tutorial and put it on the internet. The people who have the least knowledge of a subject are the ones who suffer the most from shoddy information because they simply don't know the information is bad. Link to comment https://forums.phpfreaks.com/topic/221355-syntex-error/page/2/#findComment-1146049 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.