In my php code, I am trying to update all rows of an sql database table that have a particular value for 2 different fields/columns. When I run the code, the updates are not being made to the sql table.
Assume I have a database called "databasename" with a table called "Pets" with these columns: "Cat" (varchar), "Dog" (varchar) & "Favorite" (boolean). I want to mark all rows that have Cat = Sylvester & Dog = Clifford with a value of 1 in the favorite column.
Here is my code:
<?php
$connect = mysqli_connect("localhost","root","","databasename");
$dog='Clifford';
$cat='Sylvester';
$query="SET sql_safe_updates=0";
$query.="UPDATE Pets SET Favorite = 1 WHERE Dog= $dog AND Cat = $cat";
mysqli_multi_query($connect,$query);
?>