dyluck Posted December 27, 2009 Share Posted December 27, 2009 Hi everyone: I have this error that is driving me nuts and after scowering google for a long time, I can't seem to get my answer. I have an array feeding a mysql query: $insert = "INSERT INTO AUTOPRODUCT (".implode(", ",$parsecolmns).") VALUES (".implode(",",$parsevals).")"; mysql_query($insert) or die(mysql_error()); One of the array values is throwing the the following 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 '://www.' at line 1 Can anyone help me get this going? Seems as though its accepting the other values except this one. Is there a reason It won't insert a URL with this array? Thanks in advance Link to comment https://forums.phpfreaks.com/topic/186409-mysql-syntax-error-driving-me-crazy/ Share on other sites More sharing options...
cags Posted December 27, 2009 Share Posted December 27, 2009 Change your code to... mysql_query($insert) or die("SQL: $insert, ERROR: " . mysql_error()); // or even better mysql_query($insert) or trigger_error("SQL: $insert, ERROR: " . mysql_error(), E_USER_ERROR); ... and show us the error message that is output. We have know way of knowing currently what your query actually looks like. It's most like a character that is not escaped properly. Link to comment https://forums.phpfreaks.com/topic/186409-mysql-syntax-error-driving-me-crazy/#findComment-984505 Share on other sites More sharing options...
dyluck Posted December 30, 2009 Author Share Posted December 30, 2009 Thanks for your help. Turns out it was because first i needed to escape the string then i had to quote (') over each of the implode entries like below. $insert = "INSERT INTO AUTOPRODUCT (".implode(", ",$parsecolmns).") VALUES ('".implode("','",$parsevals)."')";mysql_query($insert) or die(mysql_error()); thanks so much! Link to comment https://forums.phpfreaks.com/topic/186409-mysql-syntax-error-driving-me-crazy/#findComment-986022 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.