Jon12345 Posted December 11, 2006 Share Posted December 11, 2006 I have the following code to add a record into my mysql database:[code]<?php$kid="abc";$ipaddress="12342";$sid="7Search";$time = date("H:i:s");$date = date("m.d.y");$db=mysql_connect("localhost","user","pw");mysql_select_db("pmm__log",$db);$query="INSERT INTO visitor_log (ipaddress,date,time,kid,sid) VALUES ('$ipaddress','$date','$time','$kid','$sid')";mysql_query($query) or die('Database Query Error: '.mysql_error());mysql_close() ?> [/code]But it doesn't update. I cannot work out why. I get the following error message echoed to the browser:Database Query Error: 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 ''ipaddress','date','time','kid','sid') VALUES ('12342','12.11.06Any ideas what the problem might be? Permissions? Syntax?Thanks,Jon Link to comment https://forums.phpfreaks.com/topic/30277-database-not-updating/ Share on other sites More sharing options...
mattcairns Posted December 11, 2006 Share Posted December 11, 2006 This is just a guess but, try changing$date = date("m.d.y");to$date = date("Y-m-d");if the date field in your mysql database is looking for a date this is the format it would accept. Link to comment https://forums.phpfreaks.com/topic/30277-database-not-updating/#findComment-139286 Share on other sites More sharing options...
Jon12345 Posted December 11, 2006 Author Share Posted December 11, 2006 It still gives an error. Link to comment https://forums.phpfreaks.com/topic/30277-database-not-updating/#findComment-139294 Share on other sites More sharing options...
Jon12345 Posted December 11, 2006 Author Share Posted December 11, 2006 Found solution. I had two underscores here: pmm__log Link to comment https://forums.phpfreaks.com/topic/30277-database-not-updating/#findComment-139306 Share on other sites More sharing options...
mattcairns Posted December 11, 2006 Share Posted December 11, 2006 ah, so easy to overlook. Link to comment https://forums.phpfreaks.com/topic/30277-database-not-updating/#findComment-139311 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.