MySQL rows to PHP array

Discussion in 'MySQL' started by subdivisions, Nov 6, 2010.

Thread Status:
Not open for further replies.
  1. #1
    I'm trying to implement an IP ban manager in a script I'm writing. The admin cp has an option to add banned IPs to a table that looks like this:

    table: banned_ips

    +---------------+
    | ips           |
    +---------------+
    | 12.34.56.71   |
    | 11.34.46.72   |
    | 10.34.36.73   |
    | 12.34.56.74   |
    | 15.34.86.75   |
    | 16.34.96.76   |
    | 12.35.46.77   |
    | 12.36.46.78   |
    | 12.37.56.79   |
    | 12.38.16.78   |
    | 12.98.96.77   |
    +---------------+
    Code (markup):
    Now I need to find a way to put this to work. At the top of each page, I'd like to do something like:

    <?php
    if ( $_SERVER['REMOTE_ADDR'] == $an_ip_in_that_table )
    {
    include('banned.php');
    die();
    }
    ?>
    Code (markup):
    So, my question: How would I let $an_ip_in_that_table equal any IP in that table? Also, is this an efficient way of going about it? I was thinking I could also use fwrite on the htaccess file, but I really hate using files as databases.

    Thanks.
     
    subdivisions, Nov 6, 2010 IP
  2. subdivisions

    subdivisions Well-Known Member

    Messages:
    1,021
    Likes Received:
    40
    Best Answers:
    1
    Trophy Points:
    145
    #2
    Figured this out, can close.
     
    subdivisions, Nov 6, 2010 IP
Thread Status:
Not open for further replies.