From:             nav at nc dot ru
Operating system: Windows XP
PHP version:      4.3.6
PHP Bug Type:     MySQL related
Bug description:  mysql_afftected_rows returns 0 even when updates record

Description:
------------
I've got the problem similar to already reported here.

mysql_afftected_rows sometimes returns 0, sometimes 1. Although actually
it does UPDATES the record. This query changes user login (password,
e-mail) in the table "user" (see below. If it matters, MySQL is
3.23.53-max, Apache is 1.3.27):

Reproduce code:
---------------
mysql_query("UPDATE user SET ".$setRequest." WHERE login =
'$userCurrentLogin' AND password = md5('$userCurrentPass')");
/* $setRequest is the string compiled conditionally, but I've just printed
whole query string and it looked correct:

UPDATE user SET login = 'aaa' WHERE login = 'bbb' AND password =
md5('ccc') */

$num = mysql_affected_rows();
if ($num == 0) $errorMsg = "Could not complete your request. Check the
data";
else if ($num == -1) $errorMsg = "Database error. Try again later";
else $changeMsg = "Your data has been successfully changed";

Expected result:
----------------
Of course, I expect correct work of mysql_affected_rows :)

Actual result:
--------------
BUT the result ($num) is sometimes 0, sometimes 1, even if the record is
actually updated.

-- 
Edit bug report at http://bugs.php.net/?id=28871&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=28871&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=28871&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=28871&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=28871&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=28871&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=28871&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=28871&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=28871&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=28871&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=28871&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=28871&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=28871&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=28871&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=28871&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=28871&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=28871&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=28871&r=float

Reply via email to