lucerias Posted November 15, 2006 Share Posted November 15, 2006 I tried to insert the the record into database but i dont know where went wrong, i have been looking through the code for many times but can't find the error. Please take note that field can be null in the database. Thank you.Query Failed:INSERT into freights set id='107f5004-4b8a-b480-5ed7-455acab5b50c', name='Freight Analysis', date_entered='20061115160537', date_modified='20061115160537', modified_user_id='f29bcbdf-6f4e-5979-8867-44f3a332b364', assigned_user_id='f29bcbdf-6f4e-5979-8867-44f3a332b364', date_implemented='', date_reported='2006', parent_type='Accounts', parent_id='', parent_name='', from='Singapore', to='', weight='', inco_term='FOB', forwarder='', rate='', security='', fuel='', other='', misc='', local_handling='', currency='US Dollar', total=''::MySQL error 1064: 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 'from='Singapore', to='', weight='', inco_term='FOB', forwarder= Quote Link to comment Share on other sites More sharing options...
Psycho Posted November 15, 2006 Share Posted November 15, 2006 If fields are empty you do not need to include them in the INSERT statement. So you could try the following:[code]INSERT into freightsSET id='107f5004-4b8a-b480-5ed7-455acab5b50c', name='Freight Analysis', date_entered='20061115160537', date_modified='20061115160537', modified_user_id='f29bcbdf-6f4e-5979-8867-44f3a332b364', assigned_user_id='f29bcbdf-6f4e-5979-8867-44f3a332b364', date_reported='2006', parent_type='Accounts', from='Singapore', inco_term='FOB', currency='US Dollar'[/code]Does that work? The only thing I can think is the problem is if one of the null fields in your script is numeic only and it doesnt like the face you are trying to insert an empty string, which is NOT the same thing as null. Quote Link to comment Share on other sites More sharing options...
lucerias Posted November 15, 2006 Author Share Posted November 15, 2006 Those all are linked with html form text box, i once tried to enter value for them accordingly but still failed. Thank you Quote Link to comment Share on other sites More sharing options...
Psycho Posted November 15, 2006 Share Posted November 15, 2006 Well a few other things I can think of:1) Make sure you are entering values that match the field types - i.e. don't enter a string into a text field. I'm not sure, but I see that you are enclosing all the values in single quotes, I don't know if that is proper for a numeric type field. I only enclose string value in quotes.2) Maybe one of your field names is a reserved name (possibly rate?). Try enclosing the field names in single back quote. Quote Link to comment 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.