Question by Bjorn Seigers
I’m trying to put an ip-address in my database.
If I do an echo like this:
But if I’m trying to put it in a variable or in the database it gives nothing, so in my database it says: NULL
The commands I used for that:
$ip = $_SERVER['REMOTE_ADDR']; mysql_query("UPDATE users SET last_ip='".$ip."' WHERE id=".$row['id']) or die(mysql_error());
I don’t know what I’m doing wrong.
Can someone help me with this please?
Answer by Starx
Your code is correct and should work. Unless as commented by @wallyk, the data type of the ip field is unsupported one.
However, just to make sure wrap the WHERE condition in
' (Single Quote) and try.