DELETE FROM statement not working

血红的双手。 提交于 2020-01-07 07:59:38

问题


I have a table in a database called 'threads' and I want to delete a row where the id is equal to $forumid which is set by the URL. The URL looks something like this: domain.com/viewThread.php?forumid=1 I am getting this using

 $forumid = $_GET['forumid'];

and I am sure that this is working because I use

echo $forumid;

and it works correctly. But when I go to delete a row using

$db->query("DELETE FROM threads WHERE id='$forumid'");

its not working for some reason. Can somebody please help me with this? Is it possible that there is something wrong with my phpMyAdmin or mySQL database?


回答1:


Try the below query

$db->query("DELETE FROM threads WHERE id='.$forumid.'");



回答2:


Check the query

("DELETE FROM threads WHERE id= '.$forumid.'");



回答3:


Try by using any of the below codes.

$db->query("DELETE FROM threads WHERE id='.$forumid.'");

OR

$db->query("DELETE FROM threads WHERE id=$forumid");


来源:https://stackoverflow.com/questions/29361203/delete-from-statement-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!