Pyro4816 Posted November 28, 2006 Share Posted November 28, 2006 ok, well i need some help with if else and variables. I want to change a variable if a condition is met, but so far it has'nt worked, can anyone help me, here is an example: [code]<?php$loginm = "1";if($loginm = "1"){$loginm = "2";echo 'loginm changed to 2<br />';echo $loginm;echo '<br />';}if ($loginm="1"){echo 'maby not<br />';echo $loginm;echo '<br />';}else{echo 'else';}?>[/code]what i want it to do is change the variable from that point on instead of it reverting in another section. Link to comment https://forums.phpfreaks.com/topic/28799-simple-variable-question/ Share on other sites More sharing options...
Psycho Posted November 28, 2006 Share Posted November 28, 2006 In your conditionals (if statemetns you need to use double equal signs to test for equality. When you use a single equal sign it is assigning the value.This[code]if($loginm = "1"){[/code]means attempt to assign the value 1 to the variable $loginm. If it can then the condition passes, if it cannot then the condition fails.You need to use this[code]if($loginm == "1"){[/code] Link to comment https://forums.phpfreaks.com/topic/28799-simple-variable-question/#findComment-131862 Share on other sites More sharing options...
Pyro4816 Posted November 28, 2006 Author Share Posted November 28, 2006 thanks Link to comment https://forums.phpfreaks.com/topic/28799-simple-variable-question/#findComment-131871 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.