我想從表中刪除所有行,但它不工作。當我做echo $mydb->error;
它給了我下面的:刪除*從表不工作
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 '* FROM messages where from_user = ? and id = ?'
$user = 'currentuser';
if (isset($_POST['delete'])) {
if(!empty($_POST['id'])){
$id = $_POST['id'];
$mydb = new mysqli('localhost', 'root', '', 'database');
$stmt = $mydb->prepare("DELETE * FROM messages where from_user = ? and id = ? ");
echo $mydb->error;
$stmt->bind_param('ss', $user, $id);
foreach ($_POST['id'] as $id) {
$stmt->execute();
}
echo"The Message deleted permanently";
}
}
'DELETE *'無效。你只需要'DELETE FROM ...' – Brad
你可以刪除'*'和'FROM' –