Select with INET_ATON($IP)

this is mind boggling! I set the ip field to the current ip, and when i check the field later, it returns no results. Here's the code:

$ip_address = $_SERVER['REMOTE_ADDR'];

if($formtype == "login") {
//if user just logged in, update his IP in 'users'
if (mysql_fetch_array(mysql_query("SELECT * FROM users WHERE username='$username' AND password=MD5('$password')",$db)))
mysql_query("UPDATE users SET ip=INET_ATON('$ip_address') WHERE username='$username' AND password=MD5('$password') LIMIT 1",$db);
else {
echo "Problem";
}//this part works, the ip field is updated when it's different

$result = mysql_query("SELECT * FROM users WHERE ip=INET_ATON('$ip_address') AND password=MD5('$password')",$db);

if ($myrow = mysql_fetch_array($result)) DO STUFF;
//this part always returns false. it works if i remove the "ip=INET_ATON('$ip_address')" and only check password.

My only thought is that maybe mysql only allows one query per page load? or maybe theupdate doesn't take effect fast enough so the old ip is in the table? I'm new to mysql, so I have no idea. Any help is appreciated! Thanks a lot!
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!