Jump to content

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!

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.