I have some PHP code to execute multi queries and one of the queries has an error in it. But PHP is not detecting it. Here's the code
$updateCategoriesQ = "DELETE FROM category_products WHERE product = $id; INSERT INTO category_products (category, products) VALUES ";
foreach ($product['categories'] as $key) {
$updateCategoriesQ .= "(".mysqli_real_escape_string($connect, $key)."', $id), "; //error is here in the quote
}
$updateCategoriesQ = rtrim($updateCategoriesQ, ', ');
o($updateCategoriesQ);
$updateCategories = mysqli_multi_query($connect, $updateCategoriesQ);
if($updateCategories){
o('query ok'); //receives this output (wrapper function for echo)
}
The query that forms is
DELETE FROM category_products WHERE product = 1; INSERT INTO category_products (category, products) VALUES (1', 1), (2', 1)
The second query has an error but PHP says its ok. If I create an error in the first query (delete) then it does throws the error but not if the error is in the second query. Is there a different method of capturing error here?