I want to get a simple error message, when the update of my SQL database failed.
foreach($animals as $row) {
$cat = "234";
$sql = "UPDATE animals set cat2 = ? WHERE cat1 = ?";
$q = $pdo->prepare($sql);
$q->execute(array($cat,$cat));
}
if ($q->execute(array($cat,$cat)))
{
echo "success";
}
else
{
echo "failure";
}
But even if the update failed and nothing is updated, I get the message: success.