Jump to content

mysql syntax error?


Pacopag

Recommended Posts

Hi.  I'm having a problem that is making me hostile.

 

All I'm trying to do is to write the result of

$phpgetbrowser = mysql_real_escape_string(print_r(get_browser(null, true), true));

to a mysql table.  The data type in the table I'm using is varchar(800).

 

So I do

$sql = "insert into browsers values ('".$phpgetbrowser."')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}

 

What's making me crazy is that I copied and pasted this latter code from elsewhere in the script, where it works fine.  I'm sure that the mysql connection has already been made, and that $phpgetbrowser is initialized.  I get the following error

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 ''Array\n(\n    [browser_name_regex] => ^mozilla/5\\.0 (.*linux x86_64.*) applewe' at line 1

 

Any help would make me a much happier man.  Thanks.

Link to comment
Share on other sites

Your actual code must be doing something to the $phpgetbrowser variable in between where you are assinging the string to it and where you are using it in the query.

 

Post all the code between and including the lines of code where you are assigning it and where you are using it in the query.

 

The error message is indicating that you have an un-escaped single quote right before the word Array...

Link to comment
Share on other sites

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.