任何人都知道为什么出于这两个mySQL请求,第一个有效,第二个没有?
$bdd->exec('UPDATE users SET status = \'registered\' WHERE username="' . $userz . '"'); // working:)
$bdd->exec('DELETE ' . $_SESSION['prenom'] . 'friendlist WHERE name="' . $_POST['deletefriend'] . '"'); // not working :(
没有显示错误,但数据不会在数据库中删除。
答案 0 :(得分:2)
尝试
$bdd->exec('DELETE FROM `' . $_SESSION['prenom'] . 'friendlist` WHERE name="' . mysql_real_escape_string($_POST['deletefriend']) . '"');
或者喜欢 可以使用
$bdd->exec("DELETE FROM ". $_SESSION['prenom'] . "friendlist WHERE friendname='".$_POST['deletefriend']."'");
从table_name中删除....将是
的语法