我试图执行此代码,但我的代码因为某些原因无法插入表中而死亡。给出的错误是“存储到表时出错”我有查看我的代码,但不能看到我的PDO插入到查询或php错误日志中有任何问题。PDO查询没有插入,也没有错误
try {
$result = $s3->putObject([
'Bucket' => $config['s3']['bucket'],
'Key' => "uploads/{$name_of_uploaded_file}",
'Body' => fopen($path_of_uploaded_file, 'rb'),
'ACL' => 'public-read'
]);
if (is_uploaded_file($_FILES['uploaded_file']['size'])){
//send items to pending database
//inserts in pending db
$sql = "INSERT INTO pending (id,photo,title,description,name,pLike,pDislike) VALUES ('', :photo, :title, :description, :name, :pLike, :pDislike)";
$stmt = $conn->prepare($sql);
$stmt->bindParam(':title', $title);
$stmt->bindParam(':photo', $result);
$stmt->bindParam(':description', $story);
$stmt->bindParam(':name', $first_name);
$stmt->bindValue(':pLike', 0, PDO::PARAM_INT);
$stmt->bindValue(':pDislike', 0, PDO::PARAM_INT);
$stmt->execute();
}else {
die("there was an error in storing to table");
}
//remove the file
unlink($path_of_uploaded_file);
} catch(S3Exception $e){
die("there was an error");
}
ok了第一部分,所以我改变了你什么建议,但它给了我这个错误:在空上调用一个成员函数准备()这是因为(is_uploaded_file($ _ FILES ['uploaded_file'] ['tmp_name']))为空? – Gianni
你知道我在mypart上有一个新人的错误。准备应该是pdo而不是conn。对不起,并非常感谢帮助我澄清 – Gianni
@ user4589398哦,所以它支持'$ pdo' lol:D错字。很高兴这有帮助 – Ghost