944,164 Members | Top Members by Rank

Ad:
  • MySQL Discussion Thread
  • Unsolved
  • Views: 13178
  • MySQL RSS
Mar 28th, 2005
0

checking if a value exists

Expand Post »
how would you check if a value exists in a database? i want to use this for ip blocking so it will check if your ip is on the list and if so, it will not let you access a specfic page.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
endusto is offline Offline
1 posts
since Mar 2005
Mar 29th, 2005
0

Re: checking if a value exists

I believe there's a php command to get a user's IP address. Store that in a variable and compare it to all the values in the database where you have blocked IP's stored.

Something like this in PHP I think would do it.
[php]
$isBlocked = false;
$result = mysql_db_query("$database", "SELECT blocked_ip FROM ip_table");
//loop through all rows returned by result
while ($row = mysql_fetch_array($result))
{
if ($user_IP = $row["blocked_ip"])
{
$isBlocked = true;
}
}
if ($isBlocked)
{

//redirect to YOU ARE BLOCKED page
}
[/php]


Also, as this seems related to your subject of ip blocking:
http://daniweb.com/techtalkforums/thread2176.html
Reputation Points: 92
Solved Threads: 51
Practically a Posting Shark
Phaelax is offline Offline
856 posts
since Mar 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in MySQL Forum Timeline: query problem
Next Thread in MySQL Forum Timeline: Query hell





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC