Jump to content

PHP link to MYSQL error


lucerias

Recommended Posts

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=
Link to comment
https://forums.phpfreaks.com/topic/27315-php-link-to-mysql-error/
Share on other sites

If fields are empty you do not need to include them in the INSERT statement. So you could try the following:
[code]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_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.
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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.