Building Chinese Web Sites using PHP
Dr. Herong Yang, Version 2.11

Commonly Used MySQL Functions

This section provides a list of commonly used MySQL functions.

Once MySQL module, php_mysql.dll, is loaded into PHP, it offers a large number functions to help you to access MySQL servers and perform database related tasks. Some commonly used MySQL functions are:

  • mysql_connect - Open a connection to a MySQL Server
  • mysql_select_db - Select a MySQL database
  • mysql_close - Close MySQL connection
  • mysql_query - Send a MySQL query to the current database
  • mysql_affected_rows - Get number of affected rows in previous MySQL operation
  • mysql_client_encoding - Returns the name of the character set
  • mysql_errno - Returns the numerical value of the error message from previous MySQL operation
  • mysql_error - Returns the text of the error message from previous MySQL operation
  • mysql_fetch_array - Fetch a result row as an associative array, a numeric array, or both
  • mysql_fetch_lengths - Get the length of each output in a result
  • mysql_fetch_object - Fetch a result row as an object
  • mysql_fetch_row - Get a result row as an enumerated array
  • mysql_free_result - Free result memory
  • mysql_field_len - Returns the length of the specified field
  • mysql_field_name - Get the name of the specified field in a result
  • mysql_field_table - Get name of the table the specified field is in
  • mysql_field_type - Get the type of the specified field in a result
  • mysql_info - Get information about the most recent query
  • mysql_insert_id - Get the ID generated from the previous INSERT operation
  • mysql_num_fields - Get number of fields in result
  • mysql_num_rows - Get number of rows in result
  • mysql_field_seek - Set result pointer to a specified field offset
  • mysql_fetch_field - Get column information from a result and return as an object
  • mysql_result - Get result data

Sections in This Chapter

php_mysql.dll - Configuring PHP to Use MySQL Module

Commonly Used MySQL Functions

mysql_connect() - Creating MySQL Connections

INSERT INTO - Inserting New Records

SELECT - Running Database Queries

UPDATE - Modifying Database Records

Dr. Herong Yang, updated in 2007
Commonly Used MySQL Functions