visionaire Posted October 23, 2010 Share Posted October 23, 2010 Hello all, I am terribly confused about the following code, for some reason $tourn keeps going back to 0 for no reason! This code: <?php include 'header.php'; $tourn = $_GET['extourn']; echo "first ".$tourn."<br />"; if($tourn=0){ echo "tourn1 is ".$tourn."<br />"; } else{ echo "tourn2 is ".$tourn."<br />"; } ?> returns this: first 4 tourn2 is 0 While tourn2 should return 4 as well. I have tried a million different versions, including switches and everything and just can't understand it. Please help! Quote Link to comment https://forums.phpfreaks.com/topic/216651-_get-variable-goes-to-0/ Share on other sites More sharing options...
Pikachu2000 Posted October 23, 2010 Share Posted October 23, 2010 You set it to zero here: if($tourn=0){ - You need to use a comparison operator == rather than an assignment operator = if( $tourn == 0 ) { Quote Link to comment https://forums.phpfreaks.com/topic/216651-_get-variable-goes-to-0/#findComment-1125626 Share on other sites More sharing options...
OldWest Posted October 25, 2010 Share Posted October 25, 2010 Exactly what Pikachu2000 said... I think you can also use the === operator for an exact type match. Quote Link to comment https://forums.phpfreaks.com/topic/216651-_get-variable-goes-to-0/#findComment-1126063 Share on other sites More sharing options...
visionaire Posted October 27, 2010 Author Share Posted October 27, 2010 AAAHHH I suck! Great help, thanks! Quote Link to comment https://forums.phpfreaks.com/topic/216651-_get-variable-goes-to-0/#findComment-1127010 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.