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
https://forums.phpfreaks.com/topic/119380-you-have-an-error-in-your-sql-syntax/
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.

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');

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

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.