#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2000
    Posts
    1
    Rep Power
    0
    Im using php and I have a col named IP to store IP address's and i want to check this list to make sure the IP isnt in the table before i get php to add a new row of data. whats the best way to go about this ?
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Posts
    12
    Rep Power
    0
    Create a unique index on IP should work

    create unique index indexname on table(ip);


  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    56
    Rep Power
    15
    That's probably the best way. You can also do a search like

    select * from table where ip = $ipToBeInserted;

    and check the number of rows returned before inserting the row with new IP address.

    You should probably do both.

    --Ben.


Similar Threads

  1. prevent duplicate entries in select menu
    By SeenGee in forum PHP Development
    Replies: 2
    Last Post: February 6th, 2004, 08:08 AM
  2. alternative to "on duplicate key update"
    By laker in forum MySQL Help
    Replies: 1
    Last Post: January 22nd, 2004, 11:22 AM
  3. Cronjob madness
    By eliteboo in forum Linux Help
    Replies: 10
    Last Post: July 14th, 2003, 11:49 AM
  4. prevent duplicate
    By soupman99 in forum PHP Development
    Replies: 15
    Last Post: June 19th, 2003, 04:24 PM
  5. how to prevent duplicate login with session
    By itsource in forum PHP Development
    Replies: 1
    Last Post: October 8th, 2001, 07:15 PM

IMN logo majestic logo threadwatch logo seochat tools logo