sandari Posted January 20, 2013 Share Posted January 20, 2013 My table structure is: ID int(11) ClientID int(11) ProgramType int(11) When varchar(255) Where varchar(255) HowLong varchar(255) The command is: insert into tblRehabilitationHistory (ClientID, ProgramType, When, Where, HowLong) values ('2', '1', '2009', 'Brisbane', '6 weeks'); The error message is: 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 'When, Where, HowLong) values ('2', '1', '2009', 'Brisbane', '6 weeks')' at line 1 I am at a loss to see where I have gone wrong. Any and all help will be appreciated. Link to comment Share on other sites More sharing options...
Edward Posted January 20, 2013 Share Posted January 20, 2013 The ClientID, ProgramType are both numerical values so you don't need to quote them as you have done the string values. So you could try this: insert into tblRehabilitationHistory (ClientID, ProgramType, When, Where, HowLong) values (2, 1, '2009', 'Brisbane', '6 weeks'); Link to comment Share on other sites More sharing options...
Larry Posted January 21, 2013 Share Posted January 21, 2013 You're using reserved keywords for your column names. You can do that, but in order to reference those column names, you need to enclose them in `backticks`. 1 Link to comment Share on other sites More sharing options...
sandari Posted January 26, 2013 Author Share Posted January 26, 2013 Thanks Larry, Backticks on the field names worked wonders. Link to comment Share on other sites More sharing options...
sandari Posted January 26, 2013 Author Share Posted January 26, 2013 Actually the backticks didn't make any difference but changing some of the field names did. My table structure is: now ID int(11) ClientID int(11) TypeOfProgram int(11) WhenRun varchar(255) WhereRun varchar(255) HowLong varchar(255) Thanks again for your help. Link to comment Share on other sites More sharing options...
Larry Posted January 26, 2013 Share Posted January 26, 2013 Well, I'm glad to hear you got it working, but the backticks would have solved the problem if used properly. Changing your column names makes sense regardless, though. Link to comment Share on other sites More sharing options...
Recommended Posts