Check if PHP has been compiled --with-mysql
mysql, php
Solution
There are actually multiple modules supporting MySQL (mysql, mysqli, pdo_mysql, ...). MySQLi (improved) is generally recommended for more complete support of MySQL5 features versus the original mysql module. PDO (PHP data objects) is a database abstraction layer that provides an object oriented data abstraction.
You can use `function_exists()` per the previous comments if you want to check for the existence of a specific function per module (mysql_connect, mysqli_connect, ...).
Alternatively, you can use the PHP function `extension_loaded()` to check for the extension itself (module name matching the output from phpinfo() ):
<?php
if (extension_loaded('mysql') or extension_loaded('mysqli')) {
// Looking good
}
?>
From a command line prompt, you can list all compiled-in modules with:
php -m
If you're on a unix-ish system, use `grep` to filter the output to MySQL-related modules:
php -m | grep -i mysql
If you're on Windows, use `findstr` to filter the output to MySQL-related modules:
php -m | findstr -i mysql
Problem
Possible Duplicate: Detecting mysql support in php Is there a quick way to programmatically check whether this particular PHP installation has been compiled with support for MYSQL?