Jump to content

Recommended Posts

I keep getting an error in my IF statement Parse error: syntax error, unexpected T_ISSET, expecting '('  The line its pertaining to is the second ISSET request, but I can't figure out what I did wrong.  Any ideas?  Here's my code:

 

<?php
    if(isset($_GET['category'])){
echo '<h1><span class="red_upcap">C</span>ategories</h1>' ;
   do {
    echo '<div class="categories"><a href="store.php?category='.str_replace(" ","+",strtolower($row_rs_cats['category'])).'&sub='.str_replace(" ","+",strtolower($row_rs_cats['sub'])).'"><img src="store/thumbs/'.$row_rs_cats['img_t'].'" alt="'.ucwords($row_rs_cats['category']).'" width="'.$row_rs_cats['img_t_x'].'" height="'.$row_rs_cats['img_t_x'].'" border="0" longdesc="store.php?category='.str_replace(" ","+",strtolower($row_rs_cats['category'])).'&sub='.str_replace(" ","+",strtolower($row_rs_cats['sub'])).'" /></a><br />
    <a href="store.php?category='.str_replace(" ","+",$row_rs_cats['category']).'">'.ucwords($row_rs_cats['category']).'</a></div>';
}
    while ($row_rs_cats = mysql_fetch_assoc($rs_cats));
}
else
if isset($_GET['sub'])){  /// Errors out here.
echo '<h1><span class="red_upcap">C</span>ategory: '.ucwords($row_rs_subcategories['category']).'</h1>';
   do { 
      echo '<div class="categories"><a href="itemdetail.php?itemid='.$row_rs_subcategories['itemid'].'"><img src="store/thumbs/'.$row_rs_subcategories['img_t'].'" alt="'.ucwords($row_rs_subcategories['category']).'" width="'.$row_rs_subcategories['img_t_x'].'" height="'.$row_rs_subcategories['img_t_x'].'" border="0" longdesc="itemdetail.php?itemid='.$row_rs_subcategories['itemid'].'" /></a></div>';
}
    while ($row_rs_subcategories = mysql_fetch_assoc($rs_subcategories));
}
else{
   echo '<div class="categories"><a href="store.php?category='.str_replace(" ","+",$row_rs_categories['category']).'"><img src="store/thumbs/'.$row_rs_categories['img_t'].'" alt="'.ucwords($row_rs_categories['category']).'" width="'.$row_rs_categories['img_t_x'].'" height="'.$row_rs_categories['img_t_x'].'" border="0" longdesc="store.php?category='.str_replace(" ","+",$row_rs_categories['category']).'" /></a><br />
    <a href="store.php?category='.str_replace(" ","+",$row_rs_categories['category']).'">'.ucwords($row_rs_categories['category']).'</a></div>'
}
    while ($row_rs_categories = mysql_fetch_assoc($rs_categories));
}
?>

 

Thank you so much!

Link to comment
https://forums.phpfreaks.com/topic/153507-solved-if-statement-help/
Share on other sites

Ok, it moves past the ISSET line, but fails on the last line before the end php block.

   echo '<div class="categories"><a href="store.php?category='.str_replace(" ","+",$row_rs_categories['category']).'"><img src="store/thumbs/'.$row_rs_categories['img_t'].'" alt="'.ucwords($row_rs_categories['category']).'" width="'.$row_rs_categories['img_t_x'].'" height="'.$row_rs_categories['img_t_x'].'" border="0" longdesc="store.php?category='.str_replace(" ","+",$row_rs_categories['category']).'" /></a><br />
    <a href="store.php?category='.str_replace(" ","+",$row_rs_categories['category']).'">'.ucwords($row_rs_categories['category']).'</a></div>';
}
    while ($row_rs_categories = mysql_fetch_assoc($rs_categories));
} /// Error Here
?>

 

The error is Parse error: syntax error, unexpected '}'

 

Thank you again!

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.