I want to get info about mysql support with PHP. I need a code to detect if server have mysql support.
Asked
Active
Viewed 866 times
4 Answers
7
if (extension_loaded('mysqlnd')) // or 'mysql' or 'pdo_*'
echo 'MYSQL extension is loaded';
you can also use:
if (function_exists('mysql_connect'))
echo 'MYSQL functions are available';
bcosca
- 17,071
- 5
- 38
- 51
2
Save this as info.php (name not important though) and access it through a web browser. Amongst a bunch of other info, it will tell you whether PHP was compiled with MySQL or not.
<?php
phpinfo();
?>
Hope this helps.
Valentin Flachsel
- 10,705
- 10
- 41
- 65
-
+1 : only solution given that works independantly of the API. MySQLi and PDO exist! – Vincent Savard Nov 04 '10 at 20:22
0
Do this in code with.
if (!function_exists('mysql_connect'))
{
return 'MySQL not supported by PHP on this server!';
}
Harmon Wood
- 2,917
- 1
- 14
- 12
0
if (extension_loaded('mysql')) {
echo "MySQL Installed";
} else {
echo "MySQL not installed";
}
XViD
- 306
- 1
- 5