Daftar dan Belajar Sekarang!

Mengatasi syntax error: 7 error: cannot insert multiple commands into a prepared statement

foto ocelili
22 Kontribusi 1 Coto
1 minggu yang lalu
saya mau tanya cara mengatasi error karena multiple query
$sql = "
INSERT INTO tb_trash(nama_file, tipe_file, ukuran_file, file, tanggal_upload, id_user) SELECT nama_file, tipe_file, ukuran_file, file, tanggal_upload, id_user from tb_file WHERE id_file = '$id_file' AND id_user = '$id'; 
DELETE FROM tb_file WHERE id_file = '$id_file'; 
";

try {
    $stmt = $db->prepare($sql);
    $stmt->execute();
}
catch (PDOException $e)
{
    echo $e->getMessage();
    die();
}

Jawaban
foto bosque
111 Kontribusi 40 Coto
1 minggu yang lalu
coba kayak gini
$sql = "
INSERT INTO tb_trash(nama_file, tipe_file, ukuran_file, file, tanggal_upload, id_user) VALUES('nama','type','ukuran','file','tgl','id');
SELECT nama_file, tipe_file, ukuran_file, file, tanggal_upload, id_user from tb_file WHERE id_file = '$id_file' AND id_user = '$id'; 
DELETE FROM tb_file WHERE id_file = '$id_file'; 
";
semoga berhasil


Login untuk diksusi di forum sekolah koding