|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #35537 error in mysqli when updating a record
Submitted: 2005-12-03 23:16 UTC Modified: 2005-12-07 09:08 UTC
From: andrew dot holland at unn dot ac dot uk Assigned:
Status: Not a bug Package: MySQLi related
PHP Version: 5.1.1 OS: windows xp
Private report: No CVE-ID: None
 [2005-12-03 23:16 UTC] andrew dot holland at unn dot ac dot uk
im getting an error when doing a second update on the same record in the database.

mysqli_affected_rows() always returns 0 after the first update if you are trying to update the same record.

ive used the mysql console to perform the same update and that works fine.

Reproduce code:
$conn = mysqli_connect("localhost","root","****","****");

mysqli_autocommit($conn, FALSE);

$result = mysqli_query($conn,"update users set password = '$md5' where username = '$myvar' ");
echo mysqli_affected_rows($conn)."<br />";

//check that no errors have occured or warnings
if (mysqli_warning_count($conn) == null )
	echo mysqli_affected_rows($conn)."<br />";

	if ( mysqli_affected_rows($conn) > 0)
                echo "some data";	
		mysqli_commit ($conn);
	echo "error";

Expected result:
it should return > 0 for mysqli_affected_rows and run the following code

Actual result:
returns 0 if updating the same record


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-12-03 23:25 UTC]
Please try using this CVS snapshot:
For Windows:

 [2005-12-07 02:01 UTC] andrew dot holland at unn dot ac dot uk
it was an error that was caused by generating a unique password with time() and md5() its now sorted
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Fri Dec 01 21:01:27 2023 UTC