Voodoo Jai Posted July 6, 2008 Share Posted July 6, 2008 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 More sharing options...
PseudoEvolution Posted July 6, 2008 Share Posted July 6, 2008 The first thing I noticed is the extra "(" VALUES INET_ATON(($ip)") Fix that and see if it works. Link to comment https://forums.phpfreaks.com/topic/113458-solved-storeing-an-ip-address-in-a-db/#findComment-582974 Share on other sites More sharing options...
Voodoo Jai Posted July 6, 2008 Author Share Posted July 6, 2008 removed the extra "(" but still not working, shows a blank screen now. Link to comment https://forums.phpfreaks.com/topic/113458-solved-storeing-an-ip-address-in-a-db/#findComment-582979 Share on other sites More sharing options...
jkewlo Posted July 6, 2008 Share Posted July 6, 2008 $ip=$_SERVER['REMOTE_ADDR']; mysql_query("INSERT INTO ipstore ('address') VALUES ('$ip')"); Link to comment https://forums.phpfreaks.com/topic/113458-solved-storeing-an-ip-address-in-a-db/#findComment-582988 Share on other sites More sharing options...
Voodoo Jai Posted July 6, 2008 Author Share Posted July 6, 2008 That now gives this reply 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 ''address') VALUES INET_ATON = 127.0.0.1' at line 1 Link to comment https://forums.phpfreaks.com/topic/113458-solved-storeing-an-ip-address-in-a-db/#findComment-582989 Share on other sites More sharing options...
jkewlo Posted July 6, 2008 Share Posted July 6, 2008 $ip = $_SERVER['REMOTE_ADDR']; mysql_query = "INSERT INTO ipstore VALUES inet_aton('$ip')"; try that also post all of your code it helps us alot Link to comment https://forums.phpfreaks.com/topic/113458-solved-storeing-an-ip-address-in-a-db/#findComment-582994 Share on other sites More sharing options...
Voodoo Jai Posted July 6, 2008 Author Share Posted July 6, 2008 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. Link to comment https://forums.phpfreaks.com/topic/113458-solved-storeing-an-ip-address-in-a-db/#findComment-583004 Share on other sites More sharing options...
jkewlo Posted July 6, 2008 Share Posted July 6, 2008 ah i feel slow i should of known that Link to comment https://forums.phpfreaks.com/topic/113458-solved-storeing-an-ip-address-in-a-db/#findComment-583014 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.