2013-05-20 79 views
-5

任何人都知道爲什麼出這兩個mySQL請求,第一個請求工作,第二個不工作?MySQL刪除請求不起作用

$bdd->exec('UPDATE users SET status = \'registered\' WHERE username="' . $userz . '"'); // working:) 



$bdd->exec('DELETE ' . $_SESSION['prenom'] . 'friendlist WHERE name="' . $_POST['deletefriend'] . '"'); // not working :(

沒有顯示錯誤,但數據不會在數據庫中被刪除。

+1

語法哪裏是DELETE FROM? ?? –

+3

刪除的語法是'DELETE FROM your_table WHERE your_condition' – MatRt

+0

請發佈生成的SQL查詢。謝謝。 – Raptor

回答

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']."'"); 

DELETE FROM table_name的....會爲

+1

我不知道'$ _SESSION ['prenom']'將處理表的名稱... – MatRt

+0

你應該逃避'$ _POST '變量... –

+0

我認爲它可以作爲基於會話或表名稱的表的前綴 – Gautam3164