1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Searching for an IP address in a textfile

Discussion in 'PHP' started by abluegrape, Dec 28, 2008.

  1. #1
    Hey guys.

    I have a text file that has a list of IP addresses:
    
    1.2.3.4
    5.6.7.8
    2.4.6.8
    3.5.7.9
    etc
    etc
    
    Code (markup):
    Now, I need to search this file using PHP to see if an IP address is in that list.

    I have a bit of code:
    
    $file = file_get_contents($iprecord);
    if(!strpos($file, $visitorip))
    {
         # REDIRECT TO PAGE 1
    }
    else
    {
         # REDIRECT TO PAGE 2
    }
    
    Code (markup):
    $visitorip is the IP of the person visiting the webpage.

    Now for some reason, even though the IP address is in the list, the visitor is always getting redirected to PAGE 1.
    SEMrush
    I am guessing there is a format problem but cannot figure it out so any help appreciated!!
     
    abluegrape, Dec 28, 2008 IP
    SEMrush
  2. abluegrape

    abluegrape Peon

    Messages:
    1,029
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Its okay - found the problem damned whitespace!!!
     
    abluegrape, Dec 28, 2008 IP