views:

116

answers:

2

This is driving me nuts!

I have created a query. The query is written to Windows file for future connection to the remote database.

Upon the connection using cURL, my local script uses cURL to send the query. I assemble variables using build_http_query. The cURL works just fine but the query fails. Every time. mySQL complains that query is syntactically wrong but it is CORRECT in every way. I copied the query that the sql complained - I wrote, "die($sql)" so I could copy the string of the query. I pasted it into myPHPadmin and it executed without problems. I know it had no problem connecting to the database otherwise it would die with "cannot connect to db" or "unable to connect because of wrong login" error. It always end up saying that the query itself is wrong.

I copied the query into the server side script and it failed as well even though there is NOTHING wrong with it. I had it output to the web browser and I copied it to phpadmin... it executed fine.

I thought it was something to do with newlines/returns. I removed all of them using replace function. I even code to write queries with no newlines or returns. I used semicolon to separate queries.

But it doesn't matter - it works perfectly in phpAdmin yet it failed when hard coded into the script or reading from the file!

What do you think is the issue?

UPDATE: got it working but exactly what changed was that I simply retyped the same query from the original source and it just worked. I think there's something "invisible" or a character that looks legal but is not legal that caused the query to fail.

Sorry for not editing my original question, sure didn't realize there's "Edit" link.

A: 

This is what it echo'd back to me:

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 'INSERT INTO trips (boatID, tripDay, tripStart, tripEnd, tripShared, tripRequired' at line 1 SQL: INSERT INTO trips (boatID, tripDay, tripStart, tripEnd, tripShared, tripRequired, tripNote, tripPax, tripPrice,tripRetail,tripDiscount, tripPromo, customerID, tripSync, tripStamp, tripCode) VALUES ('11','2009-08-25','0900', '1700','1', '1','this \'isnt\' wright','4','892.5','850.00','0','','168','1', NOW(), 'AG25FX934');INSERT INTO trips (boatID, tripDay, tripStart, tripEnd, tripShared, tripRequired, tripNote, tripPax, tripPrice,tripRetail,tripDiscount, tripPromo, customerID, tripSync, tripStamp, tripCode) VALUES ('11','2009-08-25','0900', '1700','1', '1','this \'isnt\' wright','4','892.5','850.00','0','','169','1', NOW(), 'age');

But if I copy that echo'd SQL on myPHPAdmin on the server where the database is located, the query runs just fine.

I also have a duplicate database on my local machine and it executed just fine as well.

netrox
Please edit your question and put this info in the question.
derobert
A: 

That's at least two queries run together; I'd guess three from the error message. You can only run one query per prepare/execute.

derobert