尝试将JPEG图像上传到我的MySQL数据库(图像为BLOB)时,出现以下错误:

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 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 'WHERE id=57 (Image)  VALUES ('ÿØÿà\0JFIF\0\0\0\0\0\0ÿá\0XExif\0\0MM\0*\0\0\' at line 1


如果您能在代码中告诉我问题,我将不胜感激。

$sql = sprintf(
"INSERT INTO recipies WHERE id=$id (Image) VALUES ('%s')", mysql_real_escape_string(file_get_contents($_FILES["image"]["tmp_name"])));
$results = mysql_query($sql) or die(mysql_error());

最佳答案

将其插入或更新到哪里。

您可能想要这样:

$sql = sprintf(
"UPDATE recipies SET Image = '%s' WHERE id=$id", mysql_real_escape_string(file_get_contents($_FILES["image"]["tmp_name"])));
$results = mysql_query($sql) or die(mysql_error());

关于php - 将JPEG上传到MySQL时出错,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/5941573/

10-16 19:12