co.ador Posted May 19, 2009 Share Posted May 19, 2009 $sql = "SELECT id,Subject FROM menusubjects"; $menu = mysql_query($sql); while($row = mysql_fetch_assoc($menu)){ echo $row['Subject']; if ($rod['Subject'] == $menu_type) { $sql2 = "SELECT * FROM regularmenu WHERE menusubjects ='$menu_type'"; //line 54 $smenu = mysql_query($sql2) while (srow = mysql_fetch_assoc($smenu)) { echo $smenu['shoename']; } } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/158737-help-i-am-getting-a-parse-error-on-line-54/ Share on other sites More sharing options...
Masna Posted May 19, 2009 Share Posted May 19, 2009 $sql = "SELECT id,Subject FROM menusubjects"; $menu = mysql_query($sql); while($row = mysql_fetch_assoc($menu)){ echo $row['Subject']; if ($rod['Subject'] == $menu_type) { $sql2 = "SELECT * FROM regularmenu WHERE menusubjects ='$menu_type'"; //line 54 $smenu = mysql_query($sql2) //missing semicolon HERE <-- ERROR ERROR ERROR while (srow = mysql_fetch_assoc($smenu)) { echo $smenu['shoename']; } } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/158737-help-i-am-getting-a-parse-error-on-line-54/#findComment-837190 Share on other sites More sharing options...
Ken2k7 Posted May 19, 2009 Share Posted May 19, 2009 Also - if ($rod['Subject'] == $menu_type) $rod? I think you meant $row. Quote Link to comment https://forums.phpfreaks.com/topic/158737-help-i-am-getting-a-parse-error-on-line-54/#findComment-837192 Share on other sites More sharing options...
gnawz Posted May 19, 2009 Share Posted May 19, 2009 Missing the $sign and also consistency of $row Quote Link to comment https://forums.phpfreaks.com/topic/158737-help-i-am-getting-a-parse-error-on-line-54/#findComment-837202 Share on other sites More sharing options...
Masna Posted May 19, 2009 Share Posted May 19, 2009 It has to do with your loops and if statements' arrangement Orly? Quote Link to comment https://forums.phpfreaks.com/topic/158737-help-i-am-getting-a-parse-error-on-line-54/#findComment-837203 Share on other sites More sharing options...
gnawz Posted May 19, 2009 Share Posted May 19, 2009 That is correct what Ken2k7 has said...also look at while (srow = mysql_fetch_assoc($smenu)) { Quote Link to comment https://forums.phpfreaks.com/topic/158737-help-i-am-getting-a-parse-error-on-line-54/#findComment-837206 Share on other sites More sharing options...
co.ador Posted May 19, 2009 Author Share Posted May 19, 2009 $sql = "SELECT id,Subject FROM menusubjects"; $menu = mysql_query($sql); while($row = mysql_fetch_assoc($menu)){ echo $row['Subject']; if ($row['Subject'] == $menu_type) { $sql2 = "SELECT * FROM regularmenu WHERE menusubjects ='$menu_type'"; //line 54 $smenu = mysql_query($sql2); while (srow = mysql_fetch_assoc($smenu)) { echo $smenu['shoename']; } } } ?> This is my new version and still it says there is a parse error on line 54 any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/158737-help-i-am-getting-a-parse-error-on-line-54/#findComment-837208 Share on other sites More sharing options...
Ken2k7 Posted May 19, 2009 Share Posted May 19, 2009 In conjunction to gnawz post above, echo $smenu['shoename']; $srow, not $smenu. Quote Link to comment https://forums.phpfreaks.com/topic/158737-help-i-am-getting-a-parse-error-on-line-54/#findComment-837210 Share on other sites More sharing options...
Masna Posted May 19, 2009 Share Posted May 19, 2009 $sql = "SELECT id,Subject FROM menusubjects"; $menu = mysql_query($sql); while($row = mysql_fetch_assoc($menu)){ echo $row['Subject']; if ($row['Subject'] == $menu_type) { $sql2 = "SELECT * FROM regularmenu WHERE menusubjects ='$menu_type'"; //line 54 $smenu = mysql_query($sql2); while ($srow = mysql_fetch_assoc($smenu)) { echo $srow['shoename']; } } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/158737-help-i-am-getting-a-parse-error-on-line-54/#findComment-837211 Share on other sites More sharing options...
gnawz Posted May 19, 2009 Share Posted May 19, 2009 Look at while (srow = mysql_fetch_assoc($smenu)) Quote Link to comment https://forums.phpfreaks.com/topic/158737-help-i-am-getting-a-parse-error-on-line-54/#findComment-837212 Share on other sites More sharing options...
KevinM1 Posted May 19, 2009 Share Posted May 19, 2009 $sql = "SELECT id,Subject FROM menusubjects"; $menu = mysql_query($sql); while($row = mysql_fetch_assoc($menu)){ echo $row['Subject']; if ($row['Subject'] == $menu_type) { $sql2 = "SELECT * FROM regularmenu WHERE menusubjects ='$menu_type'"; //line 54 $smenu = mysql_query($sql2); while (srow = mysql_fetch_assoc($smenu)) { echo $smenu['shoename']; } } } ?> This is my new version and still it says there is a parse error on line 54 any ideas? If that's the version you're currently using, mind copying the exact error message you're getting? Quote Link to comment https://forums.phpfreaks.com/topic/158737-help-i-am-getting-a-parse-error-on-line-54/#findComment-837214 Share on other sites More sharing options...
Ken2k7 Posted May 19, 2009 Share Posted May 19, 2009 Hello people, $srow, not srow. I think gnawz emphasized that. Quote Link to comment https://forums.phpfreaks.com/topic/158737-help-i-am-getting-a-parse-error-on-line-54/#findComment-837216 Share on other sites More sharing options...
KevinM1 Posted May 19, 2009 Share Posted May 19, 2009 Hello people, $srow, not srow. I think gnawz emphasized that. Oh geez...I didn't even see the second while-loop. D'oh! Quote Link to comment https://forums.phpfreaks.com/topic/158737-help-i-am-getting-a-parse-error-on-line-54/#findComment-837219 Share on other sites More sharing options...
gnawz Posted May 19, 2009 Share Posted May 19, 2009 You might want to show more code and the error Quote Link to comment https://forums.phpfreaks.com/topic/158737-help-i-am-getting-a-parse-error-on-line-54/#findComment-837221 Share on other sites More sharing options...
co.ador Posted May 19, 2009 Author Share Posted May 19, 2009 $cat = isset($_GET['subject']) && is_numeric($_GET['subject'])?$_GET['subject']:null; $prod = isset($_GET['menu']) && is_numeric($_GET['menu'])?$_GET['menu']:null; $menu_type = $_GET['menu_type']; $sql = "SELECT id,Subject FROM menusubjects"; $menu = mysql_query($sql); while($row = mysql_fetch_assoc($menu)){ echo $row['Subject']; if ($row['Subject'] == $menu_type) { $sql2 = "SELECT * FROM regularmenu WHERE menusubjects ='$menu_type'"; //line 54 $smenu = mysql_query($sql2); while ($srow = mysql_fetch_assoc($smenu)) { echo $srow['shoename']; } } } ?> Still the parse error shows up. Parse error: parse error in C:\wamp\www\store\shoes\LunchSpecil.php on line 54 Maybe the issets are not set up properly for this queries. any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/158737-help-i-am-getting-a-parse-error-on-line-54/#findComment-837421 Share on other sites More sharing options...
co.ador Posted May 19, 2009 Author Share Posted May 19, 2009 now it works online 55 I was missing the dollar sign at the variable $smenu $smenu = mysql_query($sql2); online 54 I needed to take the qoutes around the $menu_type variable $sql2 = "SELECT * FROM regularmenu WHERE menusubjects =$menu_type"; I am trying to pass the value of the variable $menu_type from a page that links a user to a new one, that contain the queries we've been trying to fix through the entire thread together. working draft.. $cat = isset($_GET['subject']) && is_numeric($_GET['subject'])?$_GET['subject']:null; $prod = isset($_GET['menu']) && is_numeric($_GET['menu'])?$_GET['menu']:null; $menu_type = $_GET['menu_type']; $sql = "SELECT id,Subject FROM menusubjects"; $menu = mysql_query($sql); while($row = mysql_fetch_assoc($menu)){ echo $row['Subject']; if ($row['Subject'] == $menu_type) { $sql2 = "SELECT * FROM regularmenu WHERE menusubjects ='$menu_type'"; //line 54 $smenu = mysql_query($sql2); while ($srow = mysql_fetch_assoc($smenu)) { echo $srow['shoename']; } } } ?> The values of the $menu_type variable are echoing horizontally in the new page instead of vertically form as it supposed to be in the queries below. $cat = isset($_GET['subject']) && is_numeric($_GET['subject'])?$_GET['subject']:null; $prod = isset($_GET['menu']) && is_numeric($_GET['menu'])?$_GET['menu']:null; $menu_type = $_GET['menu_type']; $sql = 'SELECT id,Subject FROM menusubjects;'; $result = mysql_query($sql); if($result && mysql_num_rows($result)!=0) { echo '<ul id="nav-categories">'; while($row = mysql_fetch_assoc($result)) { $uri = 'example1.php?subject='.urlencode($row['id']); $class = !is_null($cat) && $cat==$row['id']?' class="selected"':''; echo "\t",'<li',$class,'><a href="',$uri,'">',$row['Subject'].'</a>'; if($submenu==false && !is_null($cat) && $cat == $row['id']) { // line 58 $sql2 = 'SELECT id,shoename FROM regularmenu WHERE menusubject_id = '.mysql_real_escape_string($cat).';'; $result2 = mysql_query($sql2); if($result2 && mysql_num_rows($result2)!=0) { echo "\n\t\t",'<ul class="submenu">',"\n"; while($row2 = mysql_fetch_assoc($result2)) { $uri2 = $uri.'&menu='.urlencode($row2['id']); $class2 = !is_null($prod) && $prod==$row2['id']?' class="selected"':''; echo "\t\t\t",'<li',$class,'><a href="',$uri2,'">',$row2['shoename'],'</a></li>',"\n"; } echo "\t\t",'</ul> <!-- end of ul.submenu -->',"\n"; } $submenu = true; } echo '</li>',"\n"; } echo '</ul> <!-- end of ul#nav-categories -->',"\n the new code I have post above display a menu which contains heading and subheadings below the subjects. within the last code which is the same as the one we have been discussing but with slightly differences. The differences are the <ul> tags echo '<ul id="nav-categories">' This <ul> display the headings downward and it's subheadings as well, it has links for the headings and subheadings $uri = 'example1.php?subject='.urlencode($row['id']); , and some comparisons such as, if a heading is clicked on then display the submenus and leave them displayed, if($submenu==false && !is_null($cat) && $cat == $row['id'])[[code=php:0] I want to place within the new code an if condition statement like [code=php:0]if ($row['Subject'] == $menu_type) where the $menu_type value comes from another page and only opens it's respective heading. for instance. $menu_type value coming from another page == to $row['Subject] in the page being linked to then echo the submenus. Previous page: $menu_type= "Lunch" Page where the user has been linked $row = "Lunch" then take that $menu_type == $row and echo the submenus of Lunch. How can fit a condition? Where in this code? $cat = isset($_GET['subject']) && is_numeric($_GET['subject'])?$_GET['subject']:null; $prod = isset($_GET['menu']) && is_numeric($_GET['menu'])?$_GET['menu']:null; $menu_type = $_GET['menu_type']; $sql = 'SELECT id,Subject FROM menusubjects;'; $result = mysql_query($sql); if($result && mysql_num_rows($result)!=0) { echo '<ul id="nav-categories">'; while($row = mysql_fetch_assoc($result)) { $uri = 'example1.php?subject='.urlencode($row['id']); $class = !is_null($cat) && $cat==$row['id']?' class="selected"':''; echo "\t",'<li',$class,'><a href="',$uri,'">',$row['Subject'].'</a>'; if($submenu==false && !is_null($cat) && $cat == $row['id']) { // line 58 $sql2 = 'SELECT id,shoename FROM regularmenu WHERE menusubject_id = '.mysql_real_escape_string($cat).';'; $result2 = mysql_query($sql2); if($result2 && mysql_num_rows($result2)!=0) { echo "\n\t\t",'<ul class="submenu">',"\n"; while($row2 = mysql_fetch_assoc($result2)) { $uri2 = $uri.'&menu='.urlencode($row2['id']); $class2 = !is_null($prod) && $prod==$row2['id']?' class="selected"':''; echo "\t\t\t",'<li',$class,'><a href="',$uri2,'">',$row2['shoename'],'</a></li>',"\n"; } echo "\t\t",'</ul> <!-- end of ul.submenu -->',"\n"; } $submenu = true; } echo '</li>',"\n"; } echo '</ul> <!-- end of ul#nav-categories -->',"\n any suggestions Quote Link to comment https://forums.phpfreaks.com/topic/158737-help-i-am-getting-a-parse-error-on-line-54/#findComment-837460 Share on other sites More sharing options...
gnawz Posted May 21, 2009 Share Posted May 21, 2009 Do you possibly have no such field echo $srow['shoename']; //the field shoename? in your db? Quote Link to comment https://forums.phpfreaks.com/topic/158737-help-i-am-getting-a-parse-error-on-line-54/#findComment-839453 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.