tibberous Posted September 28, 2007 Share Posted September 28, 2007 insert into log (what, when) values ('test', '1191020046') I get a syntax error. Any idea why? Quote Link to comment https://forums.phpfreaks.com/topic/71106-mysql-error-in-a-really-simple-query/ Share on other sites More sharing options...
pocobueno1388 Posted September 28, 2007 Share Posted September 28, 2007 Well, you need to show your exact code. It should look like this: <?php $query = "INSERT INTO log (what, when) VALUES ('test', '1191020046')"; $result = mysql_query($query)or die(mysql_error()); ?> Quote Link to comment https://forums.phpfreaks.com/topic/71106-mysql-error-in-a-really-simple-query/#findComment-357588 Share on other sites More sharing options...
teng84 Posted September 28, 2007 Share Posted September 28, 2007 show us whats the error your getting or maybe log is a reserve word try adding tick ` insert into `log` (what, when) values ('test', '1191020046') Quote Link to comment https://forums.phpfreaks.com/topic/71106-mysql-error-in-a-really-simple-query/#findComment-357591 Share on other sites More sharing options...
Barand Posted September 28, 2007 Share Posted September 28, 2007 "WHEN" is a mysql reserved word. LOG is OK Change the column name or use `when` (note back ticks not single quotes) http://dev.mysql.com/doc/refman/4.1/en/reserved-words.html Quote Link to comment https://forums.phpfreaks.com/topic/71106-mysql-error-in-a-really-simple-query/#findComment-357592 Share on other sites More sharing options...
tibberous Posted September 28, 2007 Author Share Posted September 28, 2007 "WHEN" is a mysql reserved word. LOG is OK Change the column name or use `when` (note back ticks not single quotes) http://dev.mysql.com/doc/refman/4.1/en/reserved-words.html Yep, you are right. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/71106-mysql-error-in-a-really-simple-query/#findComment-357611 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.