Jump to content

[SOLVED] Storeing an IP address in a db


Voodoo Jai

Recommended Posts

I am trying to store an ip address in a db without success. I have a table and are field defined as an int to store the value, I then are trying to store using  "INET_ATON" like so:

the ip value is 127.0.0.1

$ip=$_SERVER['REMOTE_ADDR']; 

mysql_query("INSERT INTO ipstore (address) VALUES INET_ATON(($ip)") 

 

I  get this msg

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INET_ATON((127.0.0.1)' at line 1

 

how should I be doing this storeage.

 

Thanks advance

Voodoojai

Link to comment
https://forums.phpfreaks.com/topic/113458-solved-storeing-an-ip-address-in-a-db/
Share on other sites

Got it working now this is the code I used:

 

mysql_query("INSERT INTO ipstore (address) VALUES (INET_ATON('$ip'))")

 

instead of

 


mysql_query("INSERT INTO ipstore (address) VALUES INET_ATON(($ip)")

the bracket was at the wrong end as well as one missing, also single quotes in the value list corrected it.

dam typos so frustrating.

 

thans for all your help guys.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.