SirChick Posted January 10, 2008 Share Posted January 10, 2008 I have a problem with my if statements Now the variable is definitely set because when i echo it ... it displays the correct number! But the if statement loads the wrong parts.... this is what i tried: When the variable is set == to 1 then it should load //code. How ever at the moment it is loading the url for the bus stop (the first url) Is this because the isset doesn't work for variables and only will work for GET and POST? If the answer is that it won't work for variables.. will it work for SESSIONS? And if not for sessions is there a way to do it without do the if ( $busessions== '' )? Because if i do that sort of check then i get a notice error about the variable not being initially set (which is unavoidable with this feature im working on) <php If (!(isset($Busession))){ ?> <a href="londonbusprocess.php?bus=1">Bus Stop</a><br> <? }ElseIF($BusSession != 1){ ?> <a href="londonbusprocess.php?bus=1">Bus Stop</a><br> <? }else{ //code } ?> Quote Link to comment https://forums.phpfreaks.com/topic/85285-isset-on-normal-variables/ Share on other sites More sharing options...
teng84 Posted January 10, 2008 Share Posted January 10, 2008 isset works in all kind of variables try <?php if (!isset($Busession)){ ?> <a href="londonbusprocess.php?bus=1">Bus Stop</a><br> <? }elseif($BusSession != 1){ ?> <a href="londonbusprocess.php?bus=1">Bus Stop</a><br> <? }else{ //code } ?> Quote Link to comment https://forums.phpfreaks.com/topic/85285-isset-on-normal-variables/#findComment-435138 Share on other sites More sharing options...
revraz Posted January 10, 2008 Share Posted January 10, 2008 Seems kinda redundant of what you're doing. The code goes to the same location if its not set or if it doesn't = 1, which to me means that it needs to = 1 to run your code? So why not just check the one value? Quote Link to comment https://forums.phpfreaks.com/topic/85285-isset-on-normal-variables/#findComment-435151 Share on other sites More sharing options...
cooldude832 Posted January 10, 2008 Share Posted January 10, 2008 saying <?php if($var == 1){ } ?> is usually the same as saying <?Php if($var == TRUE){ } ?> Quote Link to comment https://forums.phpfreaks.com/topic/85285-isset-on-normal-variables/#findComment-435161 Share on other sites More sharing options...
revraz Posted January 10, 2008 Share Posted January 10, 2008 And that has to do with what? saying <?php if($var == 1){ } ?> is usually the same as saying <?Php if($var == TRUE){ } ?> Quote Link to comment https://forums.phpfreaks.com/topic/85285-isset-on-normal-variables/#findComment-435173 Share on other sites More sharing options...
Ken2k7 Posted January 10, 2008 Share Posted January 10, 2008 You sure you didn't misspelled the first variable? You have $Busession and $BusSession. Quote Link to comment https://forums.phpfreaks.com/topic/85285-isset-on-normal-variables/#findComment-435176 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.