seany123 Posted April 29, 2009 Share Posted April 29, 2009 okay so i have a page which im using these variables.. <?php $moneygain = ""; $expgain = ""; $prisontime = ""; $nerveloss = ""; ?> what i want to know, is it possible for the above variables to have different values throughout the page? like for example is this possible? <?php if(100 > 1000){ $moneygain = "10"; $expgain = "10"; $prisontime = "50"; $nerveloss = "50"; } else if(100 <= 1000){ $moneygain = "500"; $expgain = "3"; $prisontime = "60000"; $nerveloss = "71"; } ?> is that possible? Quote Link to comment https://forums.phpfreaks.com/topic/156127-help-with-variables/ Share on other sites More sharing options...
PFMaBiSmAd Posted April 29, 2009 Share Posted April 29, 2009 A) Try it to see, B) Yes, C) That is the definition of what a variable is. It's contents are "variable" and can be set to whatever you want, any number of times, wherever you want. Quote Link to comment https://forums.phpfreaks.com/topic/156127-help-with-variables/#findComment-821847 Share on other sites More sharing options...
mrMarcus Posted April 29, 2009 Share Posted April 29, 2009 have you tried it? looks like you got the code all there, why not give it a go? best way to learn. but yes, yes it is .. the variable will assume the latter value. Quote Link to comment https://forums.phpfreaks.com/topic/156127-help-with-variables/#findComment-821848 Share on other sites More sharing options...
ignace Posted April 29, 2009 Share Posted April 29, 2009 Instead of asking such questions try it! If it doesn't work then google it! If google refuses to tell you why? Then you can come here to ask us the reason why it doesn't work Quote Link to comment https://forums.phpfreaks.com/topic/156127-help-with-variables/#findComment-821849 Share on other sites More sharing options...
seany123 Posted April 29, 2009 Author Share Posted April 29, 2009 i did try it out in a much larger more complex script... however it seemed that the variables all equaled what the first 4 was set to. i just wanted to make sure what i was doing was possible before i started tinkering with my entire code... thanks Quote Link to comment https://forums.phpfreaks.com/topic/156127-help-with-variables/#findComment-821874 Share on other sites More sharing options...
Maq Posted April 29, 2009 Share Posted April 29, 2009 what i want to know, is it possible for the above variables to have different values throughout the page? Not to be a dick, but what do you think the name, 'variable', refers to? It's because they can vary. Quote Link to comment https://forums.phpfreaks.com/topic/156127-help-with-variables/#findComment-821879 Share on other sites More sharing options...
premiso Posted April 29, 2009 Share Posted April 29, 2009 i just wanted to make sure what i was doing was possible before i started tinkering with my entire code... If you want to just "make" sure that something is do-able, why not create a test script and code something into it...that will tell you without having to modify your entire code. Hell I still create small test scripts to test theorys, new functions, or code I am modifying and planning on implementing before I modify my script to use that code. This way I can fix any issues that arise at the source and not have to worry about going through my script and fixing it there. Less code to look at the easier to fix in my opinion. Just do not be afraid to create a test script and test stuff out. It will not bite you, I promise. Quote Link to comment https://forums.phpfreaks.com/topic/156127-help-with-variables/#findComment-821893 Share on other sites More sharing options...
seany123 Posted April 29, 2009 Author Share Posted April 29, 2009 okay well can anyone let me know why this isnt working... even though i have put the variables in with new values (on line 40ish) its still echoing the same variable values i put (on line 12) <?php include("lib.php"); $player = check_user($secret_key, $db); define("PAGENAME", "Crimes"); include("templates/private_header3.php"); ?> <?php if ($_GET['crime']) { if($_GET['crime'] = "1"){ //ctest.php $moneygain = "10"; $expgain = "25"; $prisontime = "10"; $nerveloss = "1"; if ($player->nerve == 0) { echo "you dont have enough nerve!!<br>"; echo"<a href=\"http://www.mafiakillerz.co.cc/ctest.php\">[back]</a>"; exit; } if ($player->prison >= 1){ echo "you cannot commit crimes when in prison"; exit; } ///////////////////////////////////////// AWAKE 10%////////////////////////////////////////// else if ($player->nerve >=1 && $player->awake < $player->maxawake * 0.10){ //sucess / fail. $random1 = rand(1,1000); //Prison. $random2 = rand(1,100); //sucess if($random1 <= 100){ if ($player->exp + $expgain < $player->maxexp) { $query = $db->execute("update `players` set `money`=?, `exp`=?, `nerve`=? , `crimes_sucess`=?, `crimes_money`=? where `id`=?", array($player->money + $moneygain, $player->exp + $expgain, $player->nerve - $nerveloss, $player->crimes_sucess + 1, $player->crimes_money + $moneygain, $player->id )); echo "Success<br>"; echo"You Gained $$moneygain and $expgain Exp!!<br>"; echo"<a href=\"http://www.mafiakillerz.co.cc/ctest.php\">[Retry]</a> "; echo"<a href=\"http://www.mafiakillerz.co.cc/ctest.php\">[back]</a>"; echo"Money gain = $moneygain <br>"; echo"prison time = $prisontime <br>"; echo"EXP gain = $expgain<br>"; echo"Nerve loss = $nerveloss<br>"; exit; } else //player has gained a level! { $query = $db->execute("Update `players` set `level`= `level`+?, `maxexp` =?, `exp` =?, `money` = `money` + ?, `hp`=?, `maxhp`=?,`maxenergy`=`maxenergy`+?, `energy`=?, `crimes_sucess`=?, `crimes_money`=?, `maxnerve`=? where `id`=?",array(1, ($player->level+1) * 70 - 20, 0, $player->money + $moneygain, $player->maxhp + 10, $player->maxhp + 10, $player->maxenergy + 1, $player->energy = $player->maxenergy, $player->crimes_sucess + 1, $player->crimes_money + $moneygain, $player->maxnerve + 1, $player->id)); echo "Success<br>"; echo"You Gained $$moneygain and $expgain Exp!!<br>"; echo "You gained a level!<br>"; echo"<a href=\"http://www.mafiakillerz.co.cc/ctest.php\">[Retry]</a> "; echo"<a href=\"http://www.mafiakillerz.co.cc/ctest.php\">[back]</a>"; exit; } } //Fail else if ($random1 >= 101 && $random2 >= 60){ $query = $db->execute("update `players` set `nerve`=?, `crimes_failed`=? where `id`=?", array($player->nerve - $nerveloss, $player->crimes_failed + 1, $player->id )); echo "Failed<br>"; echo"<a href=\"http://www.mafiakillerz.co.cc/ctest.php\">[Retry]</a> "; echo"<a href=\"http://www.mafiakillerz.co.cc/ctest.php\">[back]</a>"; exit; } //Fail & Prison else if($random2 >= 101 && $random2 <= 59){ $query = $db->execute("update `players` set `nerve`=?, `prison`=?, `crimes_failed`=? where `id`=?", array($player->nerve - $nerveloss, $player->prison + $prisontime, $player->crimes_failed + 1,$player->id )); echo "Fail and Prison<br>"; echo"<a href=\"http://www.mafiakillerz.co.cc/prison.php\">[Prison]</a>"; exit; } } ////////////////////////////////// AWAKE 90% ///////////////////////////////////// else if ($player->nerve >=1 && $player->awake >= $player->maxawake * 0.90 && $player->awake < $player->maxawake * 1) { //Sucess / Fail. $random1 = rand(1,1000); //Prison. $random2 = rand(1,100); //Success If($random1 <= 900){ if ($player->exp + $expgain < $player->maxexp){ $query = $db->execute("update `players` set `money`=?, `exp`=?, `nerve`=?, `crimes_sucess`=?, `crimes_money`=? where `id`=?", array($player->money + $moneygain, $player->exp + $expgain, $player->nerve - $nerveloss, $player->crimes_sucess + 1, $player->crimes_money + $moneygain, $player->id )); echo "Success<br>"; echo"You Gained $$moneygain and $expgain Exp!!<br>"; echo"<a href=\"http://www.mafiakillerz.co.cc/ctest.php\">[Retry]</a> "; echo"<a href=\"http://www.mafiakillerz.co.cc/ctest.php\">[back]</a>"; echo"Money gain = $moneygain <br>"; echo"prison time = $prisontime <br>"; echo"EXP gain = $expgain<br>"; echo"Nerve loss = $nerveloss<br>"; exit; } else //player has gained a level! { $query = $db->execute("Update `players` set `level`= `level`+?, `maxexp` =?, `exp` =?, `money` = `money` + ?, `hp`=?, `maxhp`=?,`maxenergy`=`maxenergy`+?, `energy`=?, `crimes_sucess`=?, `crimes_money`=?, `maxnerve`=? where `id`=?",array(1, ($player->level+1) * 70 - 20, 0, $player->money + $moneygain, $player->maxhp + 10, $player->maxhp + 10, $player->maxenergy + 1, $player->energy = $player->maxenergy, $player->crimes_sucess + 1, $player->crimes_money + $moneygain, $player->maxnerve + 1, $player->id)); echo "Success<br>"; echo"You Gained $$moneygain and $expgain Exp!!<br>"; echo "You gained a level!<br>"; echo"<a href=\"http://www.mafiakillerz.co.cc/ctest.php\">[Retry]</a> "; echo"<a href=\"http://www.mafiakillerz.co.cc/ctest.php\">[back]</a>"; exit; } } //Fail else if($random1 >= 901 && $random2 >= 20){ $query = $db->execute("update `players` set `nerve`=?, `crimes_failed`=? where `id`=?", array($player->nerve - $nerveloss, $player->crimes_failed + 1, $player->id )); echo "Failed<br>"; echo"<a href=\"http://www.mafiakillerz.co.cc/ctest.php\">[Retry]</a> "; echo"<a href=\"http://www.mafiakillerz.co.cc/ctest.php\">[back]</a>"; exit; } //Fail and Prison else if($random2 >= 901 && $random2 <= 19){ $query = $db->execute("update `players` set `nerve`=?, `prison`=?, `crimes_failed`=? where `id`=?", array($player->nerve - $nerveloss, $player->prison + $prisontime, $player->crimes_failed + 1,$player->id )); echo "Failed and Prison<br>"; echo"<a href=\"http://www.mafiakillerz.co.cc/prison.php\">[Prison]</a> "; exit; } } ////////////////////////////////// AWAKE 100% ///////////////////////////////////// else if ($player->nerve >=1 && $player->awake >= $player->maxawake * 1) { //Sucess / Fail. $random1 = rand(1,1000); //Prison. $random2 = rand(1,100); //Sucess if ($player->prison >= 1){ echo "your in prison"; exit; } If($random1 <= 999){ if ($player->exp + $expgain < $player->maxexp){ $query = $db->execute("update `players` set `money`=?, `exp`=?, `nerve`=?, `crimes_sucess`=?, `crimes_money`=? where `id`=?", array($player->money + $moneygain, $player->exp + $expgain, $player->nerve - $nerveloss, $player->crimes_sucess + 1, $player->crimes_money + $moneygain, $player->id )); echo "Success<br>"; echo"You Gained $$moneygain and $expgain Exp!!<br>"; echo"<a href=\"http://www.mafiakillerz.co.cc/ctest.php\">[Retry]</a> "; echo"<a href=\"http://www.mafiakillerz.co.cc/ctest.php\">[back]</a>"; echo"Money gain = $moneygain <br>"; echo"prison time = $prisontime <br>"; echo"EXP gain = $expgain<br>"; echo"Nerve loss = $nerveloss<br>"; echo"Money gain = $moneygain <br>"; echo"prison time = $prisontime <br>"; echo"EXP gain = $expgain<br>"; echo"Nerve loss = $nerveloss<br>"; exit; } else //player has gained a level! { $query = $db->execute("Update `players` set `level`= `level`+?, `maxexp` =?, `exp` =?, `money` = `money` + ?, `hp`=?, `maxhp`=?,`maxenergy`=`maxenergy`+?, `energy`=?, `crimes_sucess`=?, `crimes_money`=?, `maxnerve`=? where `id`=?",array(1, ($player->level+1) * 70 - 20, 0, $player->money + $moneygain, $player->maxhp + 10, $player->maxhp + 10, $player->maxenergy + 1, $player->energy = $player->maxenergy, $player->crimes_sucess + 1, $player->crimes_money + $moneygain, $player->maxnerve + 1, $player->id)); echo "Success<br>"; echo"You Gained $$moneygain and $expgain Exp!!<br>"; echo "You gained a level!<br>"; echo"<a href=\"http://www.mafiakillerz.co.cc/ctest.php\">[Retry]</a> "; echo"<a href=\"http://www.mafiakillerz.co.cc/ctest.php\">[back]</a>"; exit; } } //Fail else if($random1 >= 1000 && $random2 >= 10){ $query = $db->execute("update `players` set `nerve`=?, `crimes_failed`=? where `id`=?", array($player->nerve - $nerveloss, $player->crimes_failed + 1, $player->id )); echo "Failed<br>"; echo"<a href=\"http://www.mafiakillerz.co.cc/ctest.php\">[Retry]</a> "; echo"<a href=\"http://www.mafiakillerz.co.cc/ctest.php\">[back]</a>"; exit; } //Fail and Prison else if($random2 >= 1000 && $random2 <= 9){ $query = $db->execute("update `players` set `nerve`=?, `prison`=?, `crimes_failed`=? where `id`=?", array($player->nerve - $nerveloss, $player->prison + $prisontime, $player->crimes_failed + 1,$player->id )); echo "Failed and Prison<br>"; echo"<a href=\"http://www.mafiakillerz.co.cc/prison.php\">[Prison]</a> "; exit; } } elseif($_GET['crime'] = "25"){ //ctest.php $moneygain = "9000"; $expgain = "4500"; $prisontime = "650"; $nerveloss = "75"; if ($player->nerve < $nerveloss) { echo "you dont have enough nerve!!<br>"; echo"<a href=\"http://www.mafiakillerz.co.cc/ctest.php\">[back]</a>"; exit; } if ($player->prison >= 1){ echo "your in prison"; exit; } ///////////////////////////////////////// AWAKE 10%////////////////////////////////////////// else if ($player->nerve >= $nerveloss && $player->awake < $player->maxawake * 0.10){ //sucess / fail. $random1 = rand(1,1000); //Prison. $random2 = rand(1,100); //sucess if($random1 <= 50){ if ($player->exp + $expgain < $player->maxexp) { $query = $db->execute("update `players` set `money`=?, `exp`=?, `nerve`=? , `crimes_sucess`=?, `crimes_money`=? where `id`=?", array($player->money + $moneygain, $player->exp + $expgain, $player->nerve - $nerveloss, $player->crimes_sucess + 1, $player->crimes_money + $moneygain, $player->id )); echo "Success<br>"; echo"You Gained $$moneygain and $expgain Exp!!<br>"; echo"<a href=\"http://www.mafiakillerz.co.cc/ctest.php\">[Retry]</a> "; echo"<a href=\"http://www.mafiakillerz.co.cc/ctest.php\">[back]</a>"; echo"Money gain = $moneygain <br>"; echo"prison time = $prisontime <br>"; echo"EXP gain = $expgain<br>"; echo"Nerve loss = $nerveloss<br>"; exit; } else //player has gained a level! { $query = $db->execute("Update `players` set `level`= `level`+?, `maxexp` =?, `exp` =?, `money` = `money` + ?, `hp`=?, `maxhp`=?,`maxenergy`=`maxenergy`+?, `energy`=?, `crimes_sucess`=?, `crimes_money`=?, `maxnerve`=? where `id`=?",array(1, ($player->level+1) * 70 - 20, 0, $player->money + $moneygain, $player->maxhp + 10, $player->maxhp + 10, $player->maxenergy + 1, $player->energy = $player->maxenergy, $player->crimes_sucess + 1, $player->crimes_money + $moneygain, $player->maxnerve + 1, $player->id)); echo "Success<br>"; echo"You Gained $$moneygain and $expgain Exp!!<br>"; echo "You gained a level!<br>"; echo"<a href=\"http://www.mafiakillerz.co.cc/ctest.php\">[Retry]</a> "; echo"<a href=\"http://www.mafiakillerz.co.cc/ctest.php\">[back]</a>"; exit; } } //Fail else if ($random1 >= 51 && $random2 >= 50){ $query = $db->execute("update `players` set `nerve`=?, `crimes_failed`=? where `id`=?", array($player->nerve - $nerveloss, $player->crimes_failed + 1, $player->id )); echo "Failed<br>"; echo"<a href=\"http://www.mafiakillerz.co.cc/ctest.php\">[Retry]</a> "; echo"<a href=\"http://www.mafiakillerz.co.cc/ctest.php\">[back]</a>"; exit; } //Fail & Prison else if($random2 >= 51 && $random2 <= 59){ $query = $db->execute("update `players` set `nerve`=?, `prison`=?, `crimes_failed`=? where `id`=?", array($player->nerve - $nerveloss, $player->prison + $prisontime, $player->crimes_failed + 1,$player->id )); echo "Fail and Prison<br>"; echo"<a href=\"http://www.mafiakillerz.co.cc/prison.php\">[Prison]</a>"; exit; } } ////////////////////////////////// AWAKE 90% ///////////////////////////////////// else if ($player->nerve >= $nerveloss && $player->awake >= $player->maxawake * 0.90 && $player->awake < $player->maxawake * 1) { //Sucess / Fail. $random1 = rand(1,1000); //Prison. $random2 = rand(1,100); //Sucess if ($player->prison >= 1){ echo "your in prison"; exit; } If($random1 <= 850){ if ($player->exp + $expgain < $player->maxexp){ $query = $db->execute("update `players` set `money`=?, `exp`=?, `nerve`=?, `crimes_sucess`=?, `crimes_money`=? where `id`=?", array($player->money + $moneygain, $player->exp + $expgain, $player->nerve - $nerveloss, $player->crimes_sucess + 1, $player->crimes_money + $moneygain, $player->id )); echo "Success<br>"; echo"You Gained $$moneygain and $expgain Exp!!<br>"; echo"<a href=\"http://www.mafiakillerz.co.cc/ctest.php\">[Retry]</a> "; echo"<a href=\"http://www.mafiakillerz.co.cc/ctest.php\">[back]</a>"; echo"Money gain = $moneygain <br>"; echo"prison time = $prisontime <br>"; echo"EXP gain = $expgain<br>"; echo"Nerve loss = $nerveloss<br>"; exit; } else //player has gained a level! { $query = $db->execute("Update `players` set `level`= `level`+?, `maxexp` =?, `exp` =?, `money` = `money` + ?, `hp`=?, `maxhp`=?,`maxenergy`=`maxenergy`+?, `energy`=?, `crimes_sucess`=?, `crimes_money`=?, `maxnerve`=? where `id`=?",array(1, ($player->level+1) * 70 - 20, 0, $player->money + $moneygain, $player->maxhp + 10, $player->maxhp + 10, $player->maxenergy + 1, $player->energy = $player->maxenergy, $player->crimes_sucess + 1, $player->crimes_money + $moneygain, $player->maxnerve + 1, $player->id)); echo "Success<br>"; echo"You Gained $$moneygain and $expgain Exp!!<br>"; echo "You gained a level!<br>"; echo"<a href=\"http://www.mafiakillerz.co.cc/ctest.php\">[Retry]</a> "; echo"<a href=\"http://www.mafiakillerz.co.cc/ctest.php\">[back]</a>"; exit; } } //Fail else if($random1 >= 851 && $random2 >= 20){ $query = $db->execute("update `players` set `nerve`=?, `crimes_failed`=? where `id`=?", array($player->nerve - $nerveloss, $player->crimes_failed + 1, $player->id )); echo "Failed<br>"; echo"<a href=\"http://www.mafiakillerz.co.cc/ctest.php\">[Retry]</a> "; echo"<a href=\"http://www.mafiakillerz.co.cc/ctest.php\">[back]</a>"; exit; } //Fail and Prison else if($random2 >= 851 && $random2 <= 19){ $query = $db->execute("update `players` set `nerve`=?, `prison`=?, `crimes_failed`=? where `id`=?", array($player->nerve - $nerveloss, $player->prison + $prisontime, $player->crimes_failed + 1,$player->id )); echo "Failed and Prison<br>"; echo"<a href=\"http://www.mafiakillerz.co.cc/prison.php\">[Prison]</a> "; exit; } } ////////////////////////////////// AWAKE 100% ///////////////////////////////////// else if ($player->nerve >= $nerveloss && $player->awake >= $player->maxawake * 1) { //Sucess / Fail. $random1 = rand(1,1000); //Prison. $random2 = rand(1,100); //Sucess if ($player->prison >= 1){ echo "your in prison"; exit; } If($random1 <= 950){ if ($player->exp + $expgain < $player->maxexp){ $query = $db->execute("update `players` set `money`=?, `exp`=?, `nerve`=?, `crimes_sucess`=?, `crimes_money`=? where `id`=?", array($player->money + $moneygain, $player->exp + $expgain, $player->nerve - $nerveloss, $player->crimes_sucess + 1, $player->crimes_money + $moneygain, $player->id )); echo "Success<br>"; echo"You Gained $$moneygain and $expgain Exp!!<br>"; echo"<a href=\"http://www.mafiakillerz.co.cc/ctest.php\">[Retry]</a> "; echo"<a href=\"http://www.mafiakillerz.co.cc/ctest.php\">[back]</a>"; echo"Money gain = $moneygain <br>"; echo"prison time = $prisontime <br>"; echo"EXP gain = $expgain<br>"; echo"Nerve loss = $nerveloss<br>"; exit; } else //player has gained a level! { $query = $db->execute("Update `players` set `level`= `level`+?, `maxexp` =?, `exp` =?, `money` = `money` + ?, `hp`=?, `maxhp`=?,`maxenergy`=`maxenergy`+?, `energy`=?, `crimes_sucess`=?, `crimes_money`=?, `maxnerve`=? where `id`=?",array(1, ($player->level+1) * 70 - 20, 0, $player->money + $moneygain, $player->maxhp + 10, $player->maxhp + 10, $player->maxenergy + 1, $player->energy = $player->maxenergy, $player->crimes_sucess + 1, $player->crimes_money + $moneygain, $player->maxnerve + 1, $player->id)); echo "Success<br>"; echo"You Gained $$moneygain and $expgain Exp!!<br>"; echo "You gained a level!<br>"; echo"<a href=\"http://www.mafiakillerz.co.cc/ctest.php\">[Retry]</a> "; echo"<a href=\"http://www.mafiakillerz.co.cc/ctest.php\">[back]</a>"; exit; } } //Fail else if($random1 >= 951 && $random2 >= 10){ $query = $db->execute("update `players` set `nerve`=?, `crimes_failed`=? where `id`=?", array($player->nerve - $nerveloss, $player->crimes_failed + 1, $player->id )); echo "Failed<br>"; echo"<a href=\"http://www.mafiakillerz.co.cc/ctest.php\">[Retry]</a> "; echo"<a href=\"http://www.mafiakillerz.co.cc/ctest.php\">[back]</a>"; exit; } //Fail and Prison else if($random2 >= 951 && $random2 <= 9){ $query = $db->execute("update `players` set `nerve`=?, `prison`=?, `crimes_failed`=? where `id`=?", array($player->nerve - $nerveloss, $player->prison + $prisontime, $player->crimes_failed + 1,$player->id )); echo "Failed and Prison<br>"; echo"<a href=\"http://www.mafiakillerz.co.cc/prison.php\">[Prison]</a> "; exit; } } } } } ?> ive had to remove about 20k lines on this but you can see what im trying to achieve. Quote Link to comment https://forums.phpfreaks.com/topic/156127-help-with-variables/#findComment-821946 Share on other sites More sharing options...
Ken2k7 Posted April 29, 2009 Share Posted April 29, 2009 Nevermind. Didn't see the edit above. One sec. Quote Link to comment https://forums.phpfreaks.com/topic/156127-help-with-variables/#findComment-821953 Share on other sites More sharing options...
seany123 Posted April 29, 2009 Author Share Posted April 29, 2009 yes sorry about that, i had to edit it down even more because i was still above the phpfreaks character limit >.< and forgot to edit where the new line were Quote Link to comment https://forums.phpfreaks.com/topic/156127-help-with-variables/#findComment-821955 Share on other sites More sharing options...
Ken2k7 Posted April 29, 2009 Share Posted April 29, 2009 What's on line 12? I don't see anything there except an empty line. What's on like 40-ish? Can you please be more specific? Can you post those two lines? Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/156127-help-with-variables/#findComment-821959 Share on other sites More sharing options...
seany123 Posted April 29, 2009 Author Share Posted April 29, 2009 sorry, i was just pointing out where i had put the variables. $moneygain = "10"; $expgain = "25"; $prisontime = "10"; $nerveloss = "1"; $moneygain = "9000"; $expgain = "4500"; $prisontime = "650"; $nerveloss = "75"; Quote Link to comment https://forums.phpfreaks.com/topic/156127-help-with-variables/#findComment-821961 Share on other sites More sharing options...
Ken2k7 Posted April 29, 2009 Share Posted April 29, 2009 That is because you're using conditionals. if($_GET['crime'] = "1"){ //ctest.php $moneygain = "10"; $expgain = "25"; $prisontime = "10"; $nerveloss = "1"; elseif($_GET['crime'] = "25"){ //ctest.php $moneygain = "9000"; $expgain = "4500"; $prisontime = "650"; $nerveloss = "75"; See the 2 blocks I posted above. If $_GET['crime'] is 1, it can't also be 25. Therefore, the second if statement is ignored. Get it now? Quote Link to comment https://forums.phpfreaks.com/topic/156127-help-with-variables/#findComment-821967 Share on other sites More sharing options...
Maq Posted April 29, 2009 Share Posted April 29, 2009 Since he was using 'elseif' then if the first 'if' is true, which it always will be in this case, the 'elseif' will never be executed. He needs to use '=='. Your code is also very inconsistent, you're using elseif's with spaces, capital 'I' for if's, very bad. Quote Link to comment https://forums.phpfreaks.com/topic/156127-help-with-variables/#findComment-821970 Share on other sites More sharing options...
seany123 Posted April 29, 2009 Author Share Posted April 29, 2009 okay so i added another = and it echos when its == 1.... however when its == 25... it doesnt echo anything. Quote Link to comment https://forums.phpfreaks.com/topic/156127-help-with-variables/#findComment-821987 Share on other sites More sharing options...
Maq Posted April 29, 2009 Share Posted April 29, 2009 You're using elseif's so if anything before that results to true, than the elseif with == "25" won't execute. Quote Link to comment https://forums.phpfreaks.com/topic/156127-help-with-variables/#findComment-822032 Share on other sites More sharing options...
premiso Posted April 29, 2009 Share Posted April 29, 2009 You're using elseif's so if anything before that results to true, than the elseif with == "25" won't execute. Not to mention if it is equal to 1 in the first place, how will it ever be equaled to 25 ??? Quote Link to comment https://forums.phpfreaks.com/topic/156127-help-with-variables/#findComment-822066 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.