Echo If IP is in Array

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
nickman013
Forum Regular
Posts: 764
Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York

Echo If IP is in Array

Post 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
User avatar
Zoxive
Forum Regular
Posts: 974
Joined: Fri Apr 01, 2005 4:37 pm
Location: Bay City, Michigan

Post by Zoxive »

Code: Select all

in_array();
-NSF
brendandonhue
Forum Commoner
Posts: 71
Joined: Mon Sep 25, 2006 3:21 pm

Post 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.
User avatar
nickman013
Forum Regular
Posts: 764
Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York

Post 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.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

your missing a semicolon, look carefully.
User avatar
nickman013
Forum Regular
Posts: 764
Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York

Post by nickman013 »

Thanks alot.
Post Reply