These two PHP MySQL queries work.
mysql_query("DELETE FROM videos WHERE id='10';");
mysql_query("DELETE FROM comments WHERE videoId='10';");
This single query fails due to a MySQL syntax error pertinent to the latter DELETE operation.
mysql_query("DELETE FROM videos WHERE id='10';DELETE FROM comments WHERE videoId='10';");
I’ve stared hard and can’t see the syntax error. What is it?
You cannot execute multiple queries with
mysql_query. If you really want to (security risk!), usemysql_multi_query. (And you should use the newermysqli_*functions). It’s a good idea two embed those two calls in a transaction.But this looks a lot like you really want to define foreign key constraints. I highly recommend them, if you are already using InnoDB.