php/mysql - checking value in database.

Associate
Joined
11 Oct 2008
Posts
268
I have the following code which displays all the i.p addresses which are stored in my banned database.

I'm am trying to make it so if the users i.p address matches one in the database it echoes a banned message rather than the page.

I have tried a few different methods over the last few days but just cannot get it working. I'm not sure if im looking too deep into it, is there a simple way to do this perhaps?

Any help would be greatly appreciated.

PHP:
$sql = 'SELECT ip FROM banned ORDER by id DESC';
mysql_select_db('oakfarm');
$retval = mysql_query( $sql, $conn );
if(! $retval )
{
  die('Could not get data: ' . mysql_error());
}
while($row = mysql_fetch_array($retval, MYSQL_ASSOC))
{

echo <<<DB
     
         $row[ip] <br> 

DB;

}
 
Back
Top Bottom