Jump to content

Need help PLEASE


advo

Recommended Posts

ok i have this warning showing up

 

Warning: in_array() [function.in-array]: Wrong datatype for second argument in /home/lalala/public_html/attack.php on line 72

 

the code i use

//same ip resrictions
$result = mysql_query("SELECT ip FROM ip_history WHERE user_id='$target[id]'");


while($row = mysql_fetch_array($result))
{
$sendtouser[]=$row['ip'];
}


$result = mysql_query("SELECT ip FROM ip_history WHERE user_id='$logged[id]'");

reconnect();

while($row = mysql_fetch_array($result))
{
if(in_array($row['ip'], $sendtouser))
{
	show_error("You cannot attack a user with the same IP.");
	break;
}
}

 

basically what i can gather is there is no ip for the user being attacked

i want to know how to stop this error tomming up if the $target[id] user has no ip in ip history any solution or fix to this would be greatly appreciated.

 

Link to comment
Share on other sites

The error is trying to tell you the second parameter isn't an array (which it needs to be). At a guess I'd say that the first query isn't returning any results and so the $sendtouser array isnever being populated. Declare the array before you loop through the results, so even if it's empty, it's still an array when it comes to your in_array() condition:

 

$sendtouser = array();

while($row = mysql_fetch_array($result))
{
   $sendtouser[]=$row['ip'];
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.