Jump to content

You have an error in your SQL syntax


herschen

Recommended Posts

I'm using the following code, but can't identify why the variable $usage, $_POST['usage'], or the usage field in my mysql database causes problems. If I take out usage, everything works fine. Any other combination of fields (when usage is included) gives me the 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 'usage, package, comment. Usage is a varchar field with 100 characters (the same as all the other fields) and $_POST['usage'] is a text field that contains the year '2010', '2011', etc. Here's the code:

 

$date = date('Y-m-d');
  $typeofinquiry = $_POST['typeofinquiry'];
  $name = $_POST['name'];
  $email = $_POST['email'];
  $phone = $_POST['phone'];
  $propertyid = $_POST['id'];
  $bldg = $_POST['bldg'];
  $size = $_POST['size'];
  $usage = $_POST['usage'];
  $package = $_POST['multiples'];
  $comments = $_POST['comments'];
  
  if ($clientemailexist == 0) {

$query = "INSERT INTO clients (date, typeofinquiry, name, email, phone, propertyid, bldg, size, usage, package, comments)
       VALUES ('$date', '$typeofinquiry', '$name', '$email', '$phone', '$propertyid', '$bldg', '$size', '$usage', '$package', '$comments')";
	   
mysql_query($query) or die(mysql_error());

Link to comment
https://forums.phpfreaks.com/topic/213843-you-have-an-error-in-your-sql-syntax/
Share on other sites

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.