digitalgod Posted October 31, 2006 Share Posted October 31, 2006 hey guys,I keep getting a mysql error but I can't seem to find what it is...here's my query mysql_query("INSERT INTO " . $prefix . "news (headline,content,thumb,website1,website2,website3,desc1,desc2,desc3,date,when,where,type) VALUES('$headline','$content','$names[0]','$web1','$web2','$web3','$desc1','$desc2','$desc3','$today','$when','$where','$type')") or die(mysql_error());and here's the error I'm getting when inserting valuesYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'when,where,type) VALUES('just testing','this is just a test','cercle.jpg','','' at line 1 Quote Link to comment https://forums.phpfreaks.com/topic/25731-mysql-error/ Share on other sites More sharing options...
wildteen88 Posted October 31, 2006 Share Posted October 31, 2006 See if wrapping backticks (`) around your field names in your query. MySQL might be getting confused as your have used MySQL keywords as your field names in your news table. The following are mysql keywords:- date- whereSo change the lower part of your query to this:`date`, when, `where`, `type` Quote Link to comment https://forums.phpfreaks.com/topic/25731-mysql-error/#findComment-117456 Share on other sites More sharing options...
digitalgod Posted October 31, 2006 Author Share Posted October 31, 2006 it's still giving me the exact same error... Quote Link to comment https://forums.phpfreaks.com/topic/25731-mysql-error/#findComment-117516 Share on other sites More sharing options...
trq Posted October 31, 2006 Share Posted October 31, 2006 Post your current query. Quote Link to comment https://forums.phpfreaks.com/topic/25731-mysql-error/#findComment-117526 Share on other sites More sharing options...
digitalgod Posted October 31, 2006 Author Share Posted October 31, 2006 here you gomysql_query("INSERT INTO " . $prefix . "news (headline,content,thumb,website1,website2,website3,desc1,desc2,desc3,`date`, when, `where`, `type`) VALUES('$headline','$content','$names[0]','$web1','$web2','$web3','$desc1','$desc2','$desc3','$today','$when','$where','$type')") or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/25731-mysql-error/#findComment-117532 Share on other sites More sharing options...
trq Posted October 31, 2006 Share Posted October 31, 2006 Alright... you might need to print out your query for debugging. What does this output?[code=php:0]$sql = "INSERT INTO " . $prefix . "news (headline,content,thumb,website1,website2,website3,desc1,desc2,desc3,`date`, when, `where`, `type`) VALUES ('$headline','$content','$names[0]','$web1','$web2','$web3','$desc1','$desc2','$desc3','$today','$when','$where','$type')";mysql_query($sql) or die(mysql_error()."SQL = ".$sql);[/code] Quote Link to comment https://forums.phpfreaks.com/topic/25731-mysql-error/#findComment-117542 Share on other sites More sharing options...
digitalgod Posted November 1, 2006 Author Share Posted November 1, 2006 Hi Thorpehere's the ouputSQL = INSERT INTO mtl_news (headline,content,thumb,website1,website2,website3,desc1,desc2,desc3,`date`, when, `where`, `type`) VALUES ('we\'re testing','this is just a test','cercle.jpg','','','','','','','2006-11-01','','','both')I don't understand why it doesn't work. The table exists and all the rows as well Quote Link to comment https://forums.phpfreaks.com/topic/25731-mysql-error/#findComment-117938 Share on other sites More sharing options...
trq Posted November 1, 2006 Share Posted November 1, 2006 Look at all those blank values. Do those fields support NULLs? Quote Link to comment https://forums.phpfreaks.com/topic/25731-mysql-error/#findComment-117943 Share on other sites More sharing options...
digitalgod Posted November 1, 2006 Author Share Posted November 1, 2006 yeah they do, I just left all those fields blank for testing purposes. And anyways whenever there's a blank in a row, that row doesn't get displayed to the user Quote Link to comment https://forums.phpfreaks.com/topic/25731-mysql-error/#findComment-117963 Share on other sites More sharing options...
digitalgod Posted November 1, 2006 Author Share Posted November 1, 2006 anyone? Quote Link to comment https://forums.phpfreaks.com/topic/25731-mysql-error/#findComment-118024 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.