Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8536085
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:34:50+00:00 2026-06-11T10:34:50+00:00

I’m new to this site, I have been coding a script to block certain

  • 0

I’m new to this site, I have been coding a script to block certain IPs from a website, the thing is, it all works with the first IP in the column, say for example the database looks like this:

http://gyazo.com/290bc2b9ef77d5b985ddd675ba0c08d1

Then only the first IP, in this case 86.70.*. would be redirected to the banned page,
If someone could please help me get my php script working:

<?php 
mysql_connect("localhost", "root", "password") or die(mysql_error());  
mysql_select_db("bans") or die(mysql_error());  
$query = mysql_query("SELECT * FROM `database`"); 
$row = mysql_fetch_array($query); 
$ip = $_SERVER['REMOTE_ADDR']; //Gets the users IP adress

$deny = array( $row[ip]); 
if (in_array ($_SERVER['REMOTE_ADDR'], $deny)) {
   header("Location: http://gabbo.org.uk/banned.php"); //What page shall the bans be sent to?
   exit(); 
}?>

I would be very grateful!
E. Rosier

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T10:34:51+00:00Added an answer on June 11, 2026 at 10:34 am

    Small change in your logic.

    <?php 
        mysql_connect("localhost", "root", "password") or die(mysql_error());  
        mysql_select_db("bans") or die(mysql_error());
        $ip = $_SERVER['REMOTE_ADDR'];
    
        # Full Text Attempt
        $query = mysql_query("SELECT `IP` FROM `database` WHERE `IP` = '$ip'");
        # Wild Card Attempt
        $query = mysql_query("SELECT `IP` FROM `database` WHERE `IP` LIKE '%$ip%'");
        # Use any one query from the above!
    
        if (mysql_num_rows($query) > 0)
        {
            header("Location: http://gabbo.org.uk/banned.php");
            die();
        }
    ?>
    

    Working

    When a user with an IP Address of 192.168.1.1 attempts to access your page and your ban list of MySQL has it, it surely returns some rows, which is greater than 1. That way, the header gives a 301 Permanent Redirection to the browser to the banned page.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a text area in my form which accepts all possible characters from
I have a jquery bug and I've been looking for hours now, I can't
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
This could be a duplicate question, but I have no idea what search terms
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.