spenceddd Posted December 28, 2009 Share Posted December 28, 2009 Hi, My form is trying to add an item to the database when a button is clicked using this extract from my code: $query="INSERT INTO Portfolio.skillsList ('ID','NAME') VALUES (NULL ,'$_POST[skillField]')"; The error is as follows: 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 ''ID','NAME') VALUES (NULL ,'IOIOI')' at line 1 Does anyone have any ideas as to what is wrong with the syntax? Thanks a lot. Spencer Link to comment https://forums.phpfreaks.com/topic/186529-sql-syntax-error-when-trying-to-insert-a-row-into-databse/ Share on other sites More sharing options...
bigglescdh Posted December 28, 2009 Share Posted December 28, 2009 You could try removing the quotes from fieldnames, or if you are using MySQL, backquoting the fieldnames: INSERT INTO Portfolio.skillsList (`ID`,`NAME`) VALUES (NULL ,'$_POST[skillField]')" HTH Link to comment https://forums.phpfreaks.com/topic/186529-sql-syntax-error-when-trying-to-insert-a-row-into-databse/#findComment-985128 Share on other sites More sharing options...
spenceddd Posted December 28, 2009 Author Share Posted December 28, 2009 Yup, that got it. Thanks very much! Link to comment https://forums.phpfreaks.com/topic/186529-sql-syntax-error-when-trying-to-insert-a-row-into-databse/#findComment-985136 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.