2K Posted May 5, 2009 Share Posted May 5, 2009 Can't seem to get if($x && $m){ if($x &! $y) to work, any help would be appreciated. This code uses a radio button and a text box for the numbers to add to the variables... if($_POST['option']){ $opts = $_POST['option']; foreach ($opts as $o) { if($o == 1){ if($y &! $x){ if($y &! $m){$page1=1; echo "You lost " . $z . " Dollars.<br />";}} if($x &! $y){ if($x &! $m){$page1=1; echo "You lost " . $d . " Euros.<br />";}} if($x && $y){ if($x &! $m){$page1=1; echo "You lost " . $zz . " Pence.<br />";}} if($x && $m){ if($x &! $y){$page1=1; echo "You lost " . $d . " Francs.<br />";}}} if($x && $y && $m){$page1=1; echo "You lost " . $zzz . " Yen.<br />";}} Quote Link to comment https://forums.phpfreaks.com/topic/156879-solved-if-issues/ Share on other sites More sharing options...
premiso Posted May 5, 2009 Share Posted May 5, 2009 I do not see where $y, $x or $m are being set. So of course it would not work... Quote Link to comment https://forums.phpfreaks.com/topic/156879-solved-if-issues/#findComment-826425 Share on other sites More sharing options...
2K Posted May 5, 2009 Author Share Posted May 5, 2009 PHP Code Page (with other code) $y = $_REQUEST['y']; $x = $_REQUEST['z']; $m = $_REQUEST['m']; Main Page that sends the request to the code page. <input name="z" type="text" /><br> <input name="y" type="text" /><br> <input name="m" type="text" /><br> Mind you this is a test, so variable names mean nothing right now... Quote Link to comment https://forums.phpfreaks.com/topic/156879-solved-if-issues/#findComment-826434 Share on other sites More sharing options...
chriscloyd Posted May 5, 2009 Share Posted May 5, 2009 here u forgot a bracket to end the first if statment <?php if($_POST['option']){ $opts = $_POST['option']; foreach ($opts as $o) { if($o == 1){ if($y &! $x){ if($y &! $m){ $page1=1; echo "You lost " . $z . " Dollars.<br />"; } } if($x &! $y){ if($x &! $m){ $page1=1; echo "You lost " . $d . " Euros.<br />"; } } if($x && $y){ if($x &! $m){ $page1=1; echo "You lost " . $zz . " Pence.<br />"; } } if($x && $m){ if($x &! $y){ $page1=1; echo "You lost " . $d . " Francs.<br />"; } } } if($x && $y && $m){ $page1=1; echo "You lost " . $zzz . " Yen.<br />"; } } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/156879-solved-if-issues/#findComment-826455 Share on other sites More sharing options...
2K Posted May 5, 2009 Author Share Posted May 5, 2009 Forgot to include that in my original copy of code... It all works fine, except the if($x && $m){if($x &! $y) line of code... Quote Link to comment https://forums.phpfreaks.com/topic/156879-solved-if-issues/#findComment-826996 Share on other sites More sharing options...
Ken2k7 Posted May 5, 2009 Share Posted May 5, 2009 What the heck is &!? Did you mean $y && !$m? Quote Link to comment https://forums.phpfreaks.com/topic/156879-solved-if-issues/#findComment-827032 Share on other sites More sharing options...
2K Posted May 6, 2009 Author Share Posted May 6, 2009 &! works just the same as && !(var) After some work on it, I discovered that $m had to be in front for the rest of it to function. if($m && $y){ if($m &! $x){$page1=1; echo "You lost " . $zz . " Pence.<br />";}} if($m && $x){ if($m &! $y){$page1=1; echo "You lost " . $d . " Francs.<br />";}} Quote Link to comment https://forums.phpfreaks.com/topic/156879-solved-if-issues/#findComment-827137 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.