Skip to Content
PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide
book

PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide

by Larry Ullman
May 2003
Intermediate to advanced
592 pages
14h 28m
English
Peachpit Press
Content preview from PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide

Updating Records with PHP

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 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

PHP and MySQL for Dynamic Web Sites: Visual Quickpro Guide, Second Edition

PHP and MySQL for Dynamic Web Sites: Visual Quickpro Guide, Second Edition

Larry Ullman

Publisher Resources

ISBN: 0321186486Purchase book