Jump to content

[SOLVED] syntax error message


atticus

Recommended Posts

I can't find the error:

 

Error, query failed : 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 ') VALUES ('album1.jpg', '38916', 'image/pjpeg', 'album1.jpg', ''

 

 

$title = $_POST[title];
$cust = $_POST[cust_id];

$query = "INSERT INTO upload2 (name, size, type, path, title, cust_id,) ".
"VALUES ('$fileName', '$fileSize', '$fileType', '$filePath', '$title', '$cust')";

mysql_query($query) or die('Error, query failed : ' . mysql_error()); 

 

it seems to come after "'$filePath',"

Link to comment
https://forums.phpfreaks.com/topic/76829-solved-syntax-error-message/
Share on other sites

Do:

 

$title = mysql_real_escape_string($_POST['title']);
$cust = mysql_real_escape_string($_POST['cust_id']);

$query = "INSERT INTO `upload2` (`name`,`size`,`typr`,`path`,`title`,`cust_id`)
             VALUES('$fileName','$fileSize','$fileType','$filePath','$title','$cust');";

mysql_query($query) or die("Error, query failed: " . mysql_error());

 

You had an extra comma after cust_id

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.