Jump to content

MySQL syntax error driving me crazy


dyluck

Recommended Posts

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

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.

 

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!

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.