Jump to content

Help I am getting a parse error on line 54


co.ador

Recommended Posts

$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']; 
}
}
}
?> 

$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']; 
}
}
}
?> 

$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?

$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']; 
}
}
}
?>

$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?

$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?

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.