我正在尝试通过 amfphp 从 as3 项目保存 jpg 的 byteArray,然后使用 php/mySQL 将其保存到我的数据库上的 BLOB。这是我的 php 函数
function saveImage($uid, $name, $tag1, $tag2, $tag3, $ba) {
$result = mysql_query("INSERT INTO images (uid,name,tag1,tag2,tag3,thumb) VALUES ('$uid','$name','$tag1','$tag2','$tag3','$ba->data');");
$error = mysql_error();
if ($error) {
return $error;
}
else {
return $result;
}
}
但我不断收到此错误:
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 '()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz¢£¤¥¦§¨©ª²³´µ¶·¸¹ºÂÃÄ' at line 1
关于如何解决这个问题有什么建议吗?
最佳答案
为了将来引用,如果你想将二进制文件保存到mysql中的blob单元,你可以使用addslashes
函数来你的数据,例如:
addslashes($blob_data);
工作代码的示例位于此处:尝试在二进制数据变量上添加斜杠。添加斜杠($变量)
关于php - 在 mySQL 中将字节数组保存到 BLOB 时出现错误 'You have an error in your SQL syntax',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14595160/