supanoob Posted October 15, 2007 Share Posted October 15, 2007 Ok so i have the followng if query but it doesnt seem to be working. Basically i want to check to see if they person is at one of 2 places by checking the co_ord_y and co_ord_x. <?php if ($town == '1') { if ($co_ord_y != '14' && $co_ord_x != '20' || $co_ord_y != '19' && $co_ord_x != '15') { echo "You are no longer near a river."; DIE(); } } ?> Well everytime i get to one of the coords it throws the "You are no longer near a river." Link to comment https://forums.phpfreaks.com/topic/73336-solved-if-queries/ Share on other sites More sharing options...
trq Posted October 15, 2007 Share Posted October 15, 2007 What do you expect to happen? And where do you set the $co_ord_y and $co_ord_x variables? ps: There called statements, not queries. And integers should not be surrounded by quotes, this makes them strings. Link to comment https://forums.phpfreaks.com/topic/73336-solved-if-queries/#findComment-370008 Share on other sites More sharing options...
supanoob Posted October 15, 2007 Author Share Posted October 15, 2007 the coords are set in the database when someone moves from 1 place to another, and if they are at the right places i want the grid for them to fish on to be shown. removing the 'from the numbers didnt help any. Link to comment https://forums.phpfreaks.com/topic/73336-solved-if-queries/#findComment-370016 Share on other sites More sharing options...
trq Posted October 15, 2007 Share Posted October 15, 2007 If your recieving the message echo 'You are no longer near a river', it is because your if statement returns true. Simple. I don't know what you want. Link to comment https://forums.phpfreaks.com/topic/73336-solved-if-queries/#findComment-370019 Share on other sites More sharing options...
supanoob Posted October 15, 2007 Author Share Posted October 15, 2007 i only want it to show when they are not on those coords if you know what i mean? so when they are not on 20x 14y or 15x 19y Link to comment https://forums.phpfreaks.com/topic/73336-solved-if-queries/#findComment-370021 Share on other sites More sharing options...
MmmVomit Posted October 15, 2007 Share Posted October 15, 2007 Try this. <?php if ($town == 1) { if (($co_ord_y != 14 && $co_ord_x != 20) || ($co_ord_y != 19 && $co_ord_x != 15)) { echo "You are no longer near a river."; DIE(); } } ?> Link to comment https://forums.phpfreaks.com/topic/73336-solved-if-queries/#findComment-370022 Share on other sites More sharing options...
supanoob Posted October 15, 2007 Author Share Posted October 15, 2007 nah that didnt work >< Link to comment https://forums.phpfreaks.com/topic/73336-solved-if-queries/#findComment-370029 Share on other sites More sharing options...
trq Posted October 15, 2007 Share Posted October 15, 2007 What does this output? <?php die("y = $co_ord_y x = $co_ord_y"); if ($town == 1) { if (($co_ord_y != 14 && $co_ord_x != 20) || ($co_ord_y != 19 && $co_ord_x != 15)) { echo "You are no longer near a river."; die(); } } ?> Link to comment https://forums.phpfreaks.com/topic/73336-solved-if-queries/#findComment-370032 Share on other sites More sharing options...
supanoob Posted October 15, 2007 Author Share Posted October 15, 2007 y = 14 x = 14 ummm, thats abit strange, even in the database it says 14y 20x Link to comment https://forums.phpfreaks.com/topic/73336-solved-if-queries/#findComment-370035 Share on other sites More sharing options...
MmmVomit Posted October 15, 2007 Share Posted October 15, 2007 Actually, this should do it <?php if ($town == 1) { if (($co_ord_y != 14 || $co_ord_x != 20) && ($co_ord_y != 19 || $co_ord_x != 15)) { echo "You are no longer near a river."; DIE(); } } ?> Link to comment https://forums.phpfreaks.com/topic/73336-solved-if-queries/#findComment-370039 Share on other sites More sharing options...
trq Posted October 15, 2007 Share Posted October 15, 2007 Hehe, because it was a typo on my part. die("y = $co_ord_y x = $co_ord_x"); Link to comment https://forums.phpfreaks.com/topic/73336-solved-if-queries/#findComment-370040 Share on other sites More sharing options...
supanoob Posted October 15, 2007 Author Share Posted October 15, 2007 yeah that seems to of worked thanks Link to comment https://forums.phpfreaks.com/topic/73336-solved-if-queries/#findComment-370042 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.