Dragon Blade Posted July 15, 2013 Share Posted July 15, 2013 Hello all, I need someone to help me out. When a userbodyguard is not in jail or hosp then they cant attack. I try to code it but it flops... $bg=mysql_query("SELECT * FROM bodyguards WHERE userID = {$_GET['ID']}"); $bgcheck=mysql_query("SELECT * FROM users WHERE userid = {$bg['userBG']}"); if($bgcheck['hospital'] == 0 && $bgcheck['jail'] ==0) { print "<hr width='50%'>Please read the error message.<hr width='50%'><h3>! ERROR</h3>This player bodyguard is not in jail or hospital, therefore you cannot attack.<br/><br/> <hr width='50%'><a href='index.php'>> Go Home</a><hr width='50%'><br /> "; $h->endpage(); exit; } I am quite sleepy if someone helps that would be great! Quote Link to comment Share on other sites More sharing options...
jcvenom Posted July 15, 2013 Share Posted July 15, 2013 Hello all, I need someone to help me out. When a userbodyguard is not in jail or hosp then they cant attack. I try to code it but it flops... $bg=mysql_query("SELECT * FROM bodyguards WHERE userID = {$_GET['ID']}"); $bgcheck=mysql_query("SELECT * FROM users WHERE userid = {$bg['userBG']}"); if($bgcheck['hospital'] == 0 && $bgcheck['jail'] ==0) { print "<hr width='50%'>Please read the error message.<hr width='50%'><h3>! ERROR</h3>This player bodyguard is not in jail or hospital, therefore you cannot attack.<br/><br/> <hr width='50%'><a href='index.php'>> Go Home</a><hr width='50%'><br /> "; $h->endpage(); exit; } I am quite sleepy if someone helps that would be great! what do you mean bodyguard is the player a body guard or is this the bodyguard mod??? Quote Link to comment Share on other sites More sharing options...
Dragon Blade Posted July 15, 2013 Author Share Posted July 15, 2013 Well I created a modification before...but I didn't finish it off. http://makewebgames.io/showthread.php/43647-User-Bodyguard Quote Link to comment Share on other sites More sharing options...
Dragon Blade Posted July 15, 2013 Author Share Posted July 15, 2013 {$bg['userBG']} is the user I am attacking bodyguard. If the userBG is in jail or hosp then I can't attack the user unless the userBG is in jail or hospital. But theres only rows if you get a BG (Hire someone) Quote Link to comment Share on other sites More sharing options...
KyleMassacre Posted July 15, 2013 Share Posted July 15, 2013 (edited) //lets make sure they are an int $_GET['ID'] = filter_input(INPUT_GET,"ID", FILTER_VALIDATE_INT); //try not to use the wild card "*" it even helps so you don't have to constantly look at your table structure all but once $bg=mysql_query("SELECT * FROM bodyguards WHERE userID = {$_GET['ID']}"); //in the next query you are using an array but you haven't instantiated one?? $b = mysql_fetch_array($bg); $bgcheck=mysql_query("SELECT * FROM users WHERE userid = {$bg['userBG']}"); //once again another array being called while ( ! $bgcheck->EOF) { // camelCase is much easier to read so sorry if you don't like it $bgCheck = mysql_fetch_array($bgcheck); if($bgCheck['hospital'] == 0 && $bgCheck['jail'] ==0) { print "<hr width='50%'>Please read the error message.<hr width='50%'><h3>! ERROR</h3>This player bodyguard is not in jail or hospital, therefore you cannot attack.<br/><br/> <hr width='50%'><a href='index.php'>> Go Home</a><hr width='50%'><br /> "; $h->endpage(); exit; } } See how that works out for ya. not tested and plus I'm on my phone so no guarantees :p also I kept it how it cause I don't know your setup you got but I would assume that the jail/hospital checks should not equal 0 right? if they are in jail then it would be > 0 wouldn't it? Edited July 15, 2013 by KyleMassacre Quote Link to comment 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.