I have a script which is throwing an error, and I'm not making much sense of it.
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 '6'' at line 2
Since this error in no way reflects what is at line two of my PHP script, I'm not sure where to look.
I did look at the SQL within the script, and other than the connection stuff (which has nothing resmbling the error), the first MySQL string is an INSERT statement broken over 2 lines.
I echoed it out, and I'm not seeing a match to the error.
There's no 6' in that section. Check the others that you didn't paste. You may have picked up a stray apostrophe. It's a simple mysql syntax error, so one of the queries is flawed.
By the way, did you know you can insert multiple rows with one INSERT statement? Then you end up using far fewer queries than this.
Ahh, I had searched for '6'', not noticing that the outer single-quotes were just delineating the string (without any results of course).
As for 6', there are probably a couple thousand matches to that tiny string. Do you have any pointers for a quick way to locate the problem ??
Going on the presumption that I picked up a stray apostrophe, I ran a find and ticked my way through the first 17 thousand rows, and all '6' strings were properly surrounded by commas, and my brain is becoming too numb to accurately plink through the rest of the records this same way.
Pointers ??
Quote:
Originally Posted by tomws
... By the way, did you know you can insert multiple rows with one INSERT statement?...
No, I didn't. That's awesome.
I'll try to pull up some info on that. Thanks.
(Any further input is always welcome.)
Last edited by mOrloff; 03-29-2010 at 06:36 PM..
Reason: fixed typo: '6 -> 6'
You can narrow it down by checking the last successfully inserted `partnumber` or `uniqueid`, then find that in the query dump. The next INSERT may be the problem.
And post the results please. Either through CLI or PHP will be fine, but make sure you view source to preserve the newlines.
Edit:
Also, can you post the PHP code you're using to build the SQL for the insertions please?
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php
You posted comma 6 which isn't a single quote. Either post the full script if possible, or search for every query that has 6 in it.
Also if it doesn't have 6, that means it's a pass query result, meaning the value from what is being inserted or updated is the value of 6, so it wouldn't show in the script.
__________________ Rowsdower! has accused me of having mental problems, and the administrator allowed it. What a great forum huh?
Correct, that was based on the suggestion that an opening quote may have been missing.
If I understand correctly, that would lead to a string of something like ...'value',6','value',...
And, yes, you are correct, the values are getting passed into the sql via php vars.
Well, I'm back, and I suspect that the problem was in the data being grabbed for the INSERT rather than the script itself.
After a change of that file, everything seems to be working.