What am I trying to do: (programmatically)
Update the status where the id If anything, if no rows are updated, we give the error: We can not get the record with the ID, otherwise the message will be successful.
Here I am using mysql_affected_rows () to know if a line is updated or not, but it always comes back 1, so the user gets a successful message, even if a line Do not get updated.
Can anyone tell me how it can be?
Here is the code:
function updates_sable ($ sql) {$ this- & gt; Final_query = $ sql; $ R = mysql_query ($ sql); If (! $ R) {$ this-> Last_ar = mysql_error (); return false; } $ Rows = mysql_affected_rows (); If ($ rows == 0) returns true; // no rows were updated; $ rows back; }
This code returns 1.
This is the reason because if you use
will print as "1", try using echo
> Correct var_dump ()
for debugging, or return your function 0 (which I think, in this case, Better option).
A small note; I think you should try to make your code a little more readable (if your question has the same layout as the code in your file in the code). Try indent code blocks, use different lines to close crisp brackets, etc. ...
Comments
Post a Comment