Jump to content

You have an error in your SQL syntax


Fredish

Recommended Posts

I recently ran into a problem I've never seen before. I try to write a row into my table (ABCmeetings), but though the script is flawless it won't write the values to the database. So I added "or die(mysql_error());" to the line to see what was wrong and the outcome was this:

 

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 's','vf','normal','2008-08-12 22:40:43','Fred Miller' )' at line 1

 

What the hell? I thought. I have no idea of how to fix this. Please help me!

Link to comment
Share on other sites

   mysql_query( "INSERT INTO ABCmeetings ( location, say, tone, date, name ) VALUES( '$bossloc','$say','$tone','$date','$boss' )" ) or die(mysql_error());

That's the query. I've checked the variables and they all check out. I am pretty sure there's nothing wrong with the code. I've connected to the database and everything, I'm sure I haven't misspelled my database name.

Link to comment
Share on other sites

I tried adding the space so it looked like this:

 

   mysql_query( "INSERT INTO ABCmeetings ( location, say, tone, indate, name ) VALUES ( '$bossloc','$say','$tone','$date','$boss' )" ) or die(mysql_error());

 

But the outcome was still the same.

Link to comment
Share on other sites

Does this work

 

mysql_query( "INSERT INTO ABCmeetings (location, say, tone, date, name) VALUES ('s','vf','normal','2008-08-12 22:40:43','Fred Miller')" ) or die(mysql_error());

 

Yes it did! so maybe it's the variables... Here they are:

 

   $say = $_POST[ 'say' ];
   $gang = $_COOKIE[ 'gang' ];
   $tone = "normal";

   $locations = mysql_query("SELECT * FROM ABCgang WHERE gang='$gang' AND rank='Boss'");
   $location = mysql_fetch_array( $locations );
   $boss = $location['name'];
   $bossloc = $location['location'];

   $date = date('Y-m-d H:i:s');

Link to comment
Share on other sites

Not familiar at all with that, but I did this:

 

   $bossloc = $location['location'];
   $bossloc = array_map( "mysql_real_escape_string", $bossloc );

 

And the values of $bossloc is nothing. Did I do something wrong? I'm sorry for being so darn newbie

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.