Jump to content
MakeWebGames

Recommended Posts

Posted

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!

Posted
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???

Posted

{$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)

Posted (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 by KyleMassacre

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...