May 2003
Intermediate to advanced
592 pages
14h 28m
English
The last technique I’ll introduce in this chapter is how to update database records with a PHP script. Doing so requires use of the UPDATE query, and its successful execution can be verified with PHP’s mysql_affected_rows() function.
While the mysql_num_rows() function will return the number of rows generated by a SELECT query, mysql_affected_rows() returns the number of rows affected by an INSERT, UPDATE, or DELETE query. It’s used like so:
$num = mysql_affected_rows($dbc);
The one argument the function takes is the database connection ($dbc), not the results of the previous query ($result).
The following example will be a script that allows registered users to change their password. It’ll demonstrate two important ...