DELETE FROM statement not working

2019-09-21 16:10发布

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?

3条回答
Melony?
2楼-- · 2019-09-21 16:31

Check the query

("DELETE FROM threads WHERE id= '.$forumid.'");
查看更多
看我几分像从前
3楼-- · 2019-09-21 16:41

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");
查看更多
做自己的国王
4楼-- · 2019-09-21 16:56

Try the below query

$db->query("DELETE FROM threads WHERE id='.$forumid.'");
查看更多
登录 后发表回答