我知道这个问题之前已被多次询问过,我已经搜索过并试图弄明白我哪里出错了,我似乎无法做到。
任何帮助都会被贬低。提前谢谢。
我已经设置了dreamweaver cc更新查询,效果很好。我想现在将图像添加到我的数据库。
这是我的问题:
$image = $_FILES['speakerimage']['tmp_name'];
$imgContent = addslashes(file_get_contents($image));
$updateSQL = sprintf("UPDATE Speakers SET speaker=%s, chkSportsCeleb=%s, chkEntertainment=%s, chkEmcee=%s, chkCFLAA=%s, chkKeynote=%s, chkAutioneer=%s, speakerImg=%s WHERE speakerID=%s",
GetSQLValueString($_POST['speaker'], "text"),
GetSQLValueString(isset($_POST['SportsCeleb']) ? "true" : "", "defined","1","0"),
GetSQLValueString(isset($_POST['Entertainment']) ? "true" : "", "defined","1","0"),
GetSQLValueString(isset($_POST['Emcee']) ? "true" : "", "defined","1","0"),
GetSQLValueString(isset($_POST['CFLAA']) ? "true" : "", "defined","1","0"),
GetSQLValueString(isset($_POST['Keynote']) ? "true" : "", "defined","1","0"),
GetSQLValueString(isset($_POST['Autioneer']) ? "true" : "", "defined","1","0"),
$imgContent,
GetSQLValueString($_POST['speakerID'], "int"));
当我在浏览器中预览我的代码时,这就是我得到的:
query = UPDATE Speakers SET speaker='John Doe', chkSportsCeleb=1, chkEntertainment=0, chkEmcee=0, chkCFLAA=1, chkKeynote=1, chkAutioneer=0, speakerImg= WHERE speakerID=59 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 speakerID=59' at line 1
我认为图片内容应该显示为胡言乱语。我无法弄清楚如何重写这个。
由于
罗兰
答案 0 :(得分:0)
尝试将图片加载到变量中,然后在UPDATE
语句中直接指定它:
$image = $_FILES['speakerimage']['tmp_name'];
$imgContent = addslashes(file_get_contents($image));
$updateSQL = sprintf("UPDATE Speakers SET speaker=%s, chkSportsCeleb=%s, chkEntertainment=%s, chkEmcee=%s, chkCFLAA=%s, chkKeynote=%s, chkAutioneer=%s, $imgContent WHERE speakerID=%s",
// ...