3mrys Posted January 13, 2008 Share Posted January 13, 2008 Hiya, I am having trouble with a very basic bit of PHP script. I have more complex things working fine on my site, and i even use the script below to achieve the same result elsewhere. Basically, i currently use the same script (apart from the variables) to show/hide a submenu depending on the section (s) the user is in as defined through the URL. However, i am trying to apply this to an include statement, so that it does the same thing, if it is in a section then display it, otherwise hide it. Above my head i have: <?php if ( $_GET["s"] == "" ) { $s = "h"; } else { $s = $_GET["s"]; } ?> And the statement is: <div <?php if ( $s == "h" ) { echo ''; } { echo 'class="noshow"'; } ?>><?php include ('modules/right/hh.php'); ?></div> Basically, it keeps on outputting the no show class whatever section i am in or whether i place it in the THEN syntax or the ELSE part of the statement. Which means my content isn't displaying. Any help would be appreciated. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/85747-solved-if-statement-errors/ Share on other sites More sharing options...
phpSensei Posted January 13, 2008 Share Posted January 13, 2008 <?php if ( $_GET['s'] == "" ) { $s = "h"; } else { $s = $_GET['s']; } ?> Whats with the double quotes? also your missing a ELSE <?php if ( $s == "h" ) { echo ''; } else{ echo 'class="noshow"'; } ?>><? Quote Link to comment https://forums.phpfreaks.com/topic/85747-solved-if-statement-errors/#findComment-437632 Share on other sites More sharing options...
Ken2k7 Posted January 13, 2008 Share Posted January 13, 2008 <?php if ( $_GET['s'] == "" ) { $s = "h"; } else { $s = $_GET['s']; } ?> Whats with the double quotes? Double quotes are valid. Quote Link to comment https://forums.phpfreaks.com/topic/85747-solved-if-statement-errors/#findComment-437635 Share on other sites More sharing options...
3mrys Posted January 13, 2008 Author Share Posted January 13, 2008 Amazing, thankyou for your very quick reply. I haven't a clue why the script wasn't working without the else seen as the menus are driven without a problem from the else part. Either way it is now working, so thankyou very much. If you want to see where this was implemented feel free: www.diverse-enterprise.co.uk/index.php Thanks again. Quote Link to comment https://forums.phpfreaks.com/topic/85747-solved-if-statement-errors/#findComment-437637 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.