Neptunus Maris Posted June 7, 2007 Share Posted June 7, 2007 MySQL is terrible at giving error reports...but anyways... does anything look wrong about this? $query = "INSERT INTO contact_jobs (ID, name, desc, posterID, price, post_date) VALUES('', '$name', '$desc', '$posterID', '$price', NOW())"; The 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 'desc, posterID, price, post_date) VALUES('', 'Test', 'sdfsf', '1', 'sds1', NOW()' at line 1' My answer is: uh...what??? Link to comment https://forums.phpfreaks.com/topic/54653-mysql-is/ Share on other sites More sharing options...
per1os Posted June 7, 2007 Share Posted June 7, 2007 $query = "INSERT INTO `contact_jobs` (`ID`, `name`, `desc`, `posterID`, `price`, `post_date`) VALUES(NULL, '$name', '$desc', '$posterID', '$price', NOW())"; try that. Link to comment https://forums.phpfreaks.com/topic/54653-mysql-is/#findComment-270278 Share on other sites More sharing options...
Neptunus Maris Posted June 7, 2007 Author Share Posted June 7, 2007 $query = "INSERT INTO `contact_jobs` (`ID`, `name`, `desc`, `posterID`, `price`, `post_date`) VALUES(NULL, '$name', '$desc', '$posterID', '$price', NOW())"; try that. Ok...ill try Link to comment https://forums.phpfreaks.com/topic/54653-mysql-is/#findComment-270280 Share on other sites More sharing options...
Neptunus Maris Posted June 7, 2007 Author Share Posted June 7, 2007 It worked...now the thing is, is that i have the same type of code in another file and it worked fine, i wonder why that didnt get any errors? hmmm... but anyways thank you very much Neptune Link to comment https://forums.phpfreaks.com/topic/54653-mysql-is/#findComment-270281 Share on other sites More sharing options...
per1os Posted June 7, 2007 Share Posted June 7, 2007 Name must be a column name that has a special meaning else where. In MySQL you can create column names such as date, password etc that have double meanings. So when you use them in a query you have to backtick ( ` ) them so MySQL knows it is looking at a column and not at the true meaning. So when it hit that spot it said, "Whoa wait a second name shouldn't be here". Link to comment https://forums.phpfreaks.com/topic/54653-mysql-is/#findComment-270283 Share on other sites More sharing options...
trq Posted June 7, 2007 Share Posted June 7, 2007 desc is a reserved word in sql. To escape reserved words in mysql you can surround the word with `backticks`. Link to comment https://forums.phpfreaks.com/topic/54653-mysql-is/#findComment-270372 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.