Page 1 of 1

Echo If IP is in Array

Posted: Sun Oct 22, 2006 1:07 pm
by nickman013
Hello,

I am trying to echo somthing so if the persons IP is in a array of IPs. I cannot get it to work. I am pretty sure I did it correctly.

My code now:

Code: Select all

<?
$ip = @$REMOTE_ADDR;
$authip = array('IP, IP, IP, IP');
if ($ip == $authip) { echo " bgcolor=orange" };
?>
IP, IP are peoples ip addresses

Posted: Sun Oct 22, 2006 1:11 pm
by Zoxive

Code: Select all

in_array();
-NSF

Posted: Sun Oct 22, 2006 1:32 pm
by brendandonhue
Your array there only has 1 element in it, I think you're also looking to put each IP as a separate value in the array.

Posted: Sun Oct 22, 2006 1:33 pm
by nickman013

Code: Select all

echo "<td align=left width=100 valign=top";
if (in_array($row4['ip'], $authip)) { 
echo " bgcolor=orange"
};
I get

Parse error: parse error, unexpected '}', expecting ',' or ';' in /home/muot/public_html/muotreport2.php on line 503

line 503 is };


Thanks for helping.

Posted: Sun Oct 22, 2006 1:34 pm
by John Cartwright
your missing a semicolon, look carefully.

Posted: Sun Oct 22, 2006 1:37 pm
by nickman013
Thanks alot.