开发者

Detecting mysql support in php

开发者 https://www.devze.com 2023-01-23 19:27 出处:网络
I want to get info about mysql support with PHP. I need a开发者_JAVA技巧 code to detect if server have mysql support.if (extension_loaded(\'mysqlnd\')) // or \'mysql\' or \'pdo_*\'

I want to get info about mysql support with PHP. I need a开发者_JAVA技巧 code to detect if server have mysql support.


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';


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.


Do this in code with.

if (!function_exists('mysql_connect'))
{
  return 'MySQL not supported by PHP on this server!';
}


if (extension_loaded('mysql')) {
    echo "MySQL Installed";
} else {
    echo "MySQL not installed";
}
0

精彩评论

暂无评论...
验证码 换一张
取 消