Hi all,
I'm testing an UPDATE query, which works fine when Col1 is not already equal to $var1 and WHERE Col2 = $var2 AND Col3 = $var3.
If I test where Col2 != $var2 and/or Col3 != $var3...I get affected_rows = 0.
If I test with Col1 already equal to $var1...I get affected_rows = 0.
Which of course makes sense.
However, what I'd like to do, is tell the difference between a Col1 already equal to $var1 update attempt...and a Col2 != $var2 and/or Col3 != $var3.
In this case, the WHERE clause failing is a much more critical issue (actually, viewed as an error) than simply Col1 already equal to $var1.
How do I differentiate between those two failed update attempts? 😕
I realize that the actual mysqli_query was sucessful, but the update wasn't (i.e. no update occured - for different reasons).
Note: the results for mysqli_error($link) is always blank in each case, and mysqli_errno($link) is always 0 (zero) in each case. Also, the echo "here" doesn't occur.
$sqlUpdate = mysqli_query($link, "UPDATE table SET Col1 = '$var1' WHERE Col2 = '$var2' AND Col3 = '$var3' LIMIT 1") or exit ("Error updating."); //This or exit is only for testing
if (mysqli_affected_rows($link) == 0) {
$result = "<font color=red><strong>Error: Update was not successful. Col1 was already same as $var1</strong></font><br>" ;
} elseif (mysqli_affected_rows($link) == -1) { //This doesn't ever seem to happen
$result = "<font color=red><strong>Error: Update was not successful. Mismatch between Col2 and $var2 and/or Col3 and $var3</strong></font><br>" ;
} else {
$result = "<font color=#006600><strong>Success Updating.</strong></font><br>" ;
}
echo "error: ".mysqli_error($link)."<br>";
echo "error no: ".mysqli_errno($link)."<br>";
$errorList = mysqli_error_list($link);
echo "error list: ".$errorList."<br>";
if ($sqlUpdate === "false") {
echo "here";
}
Edit: Also, when I try to echo "error list: " I get this error
Call to undefined function mysqli_error_list()