The MySQL functions allows you to access MySQL database servers.
For the MySQL functions to be available, you must compile PHP with MySQL support.
For compiling, use --with-mysql=DIR (the optional DIR points to the MySQL directory).
Note: For full functionality of MySQL versions greater than 4.1., use the MySQLi extension instead. If you would like to install both the mysql extension and the mysqli extension you should use the same client library to avoid any conflicts.
Installation on Linux Systems
PHP 5+: MySQL and the MySQL library is not enabled by default. Use the --with-mysql=DIR configure option to include MySQL support and download headers and libraries from www.mysql.com.
Installation on Windows Systems
PHP 5+: MySQL is not enabled by default, so the php_mysql.dll must be enabled inside of php.ini. Also, PHP needs access to the MySQL client library. A file named libmysql.dll is included in the Windows PHP distribution, and in order for PHP to talk to MySQL this file needs to be available to the Windows systems PATH.
To enable any PHP extension, the PHP extension_dir setting (in the php.ini file) should be set to the directory where the PHP extensions are located. An example extension_dir value is c:\php\ext.
Note: If you get the following error when starting the web server: "Unable to load dynamic library './php_mysql.dll'", this is because php_mysql.dll or libmysql.dll cannot be found by the system.
The behavior of the MySQL functions is affected by settings in the php.ini file.
MySQL configuration options:
There are two resource types used in the MySQL extension. The first one is the link_identifier for a database connection, the second is a resource which holds the result of a query.
Note: Most MySQL functions accept link_identifier as the last optional parameter. If it is not provided, the last opened connection is used.
PHP: indicates the earliest version of PHP that supports the function.
Since PHP 4.3 it was possible to specify additional flags for the mysql_connect() and mysql_pconnect() functions:
PHP: indicates the earliest version of PHP that supports the constant.
The mysql_fetch_array() function uses a constant for the different types of result arrays. The Below constants are defined:
Your Query was successfully sent!