我試圖執行此代碼,但我的代碼因爲某些原因無法插入表中而死亡。給出的錯誤是「存儲到表時出錯」我有查看我的代碼,但不能看到我的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