Why is only 2 of my querys working? (PHP/Mysql)
Posted
by ggfan
on Stack Overflow
See other posts from Stack Overflow
or by ggfan
Published on 2010-04-11T03:40:11Z
Indexed on
2010/04/11
3:43 UTC
Read the original article
Hit count: 203
When I remove a posting, I want it to remove the posting itself, any comments related to it, and like/dislike of the comments, and favorites that people added. So there are 4 queries that do this, but somehow only 2 of the 4 are working.
When I switch say query 2 for query 3, then query 2 works and query 3 doesn't... The table names are correct and it is getting the data via $_GET.
// Grab the data from the GET
$posting_id = $_GET['posting_id'];
// Delete the posting from the database
$query = "DELETE FROM posting WHERE posting_id=$posting_id LIMIT 1";
mysqli_query($dbc, $query) or die(mysql_error());
// Delete the comments
$query2 = "DELETE FROM comments WHERE posting_id=$posting_id ";
mysqli_query($dbc, $query2) or die(mysql_error());
// Delete the like/dislike
$query3 = "DELETE FROM comment_likedislike WHERE posting_id=$posting_id ";
mysqli_query($dbc, $query3) or die(mysql_error());
// Delete the favorites
$query4 = "DELETE FROM favorite WHERE posting_id=$posting_id ";
mysqli_query($dbc, $query4) or die(mysql_error());
© Stack Overflow or respective owner