Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detecting mysql support in php

Tags:

php

mysql

I want to get info about mysql support with PHP. I need a code to detect if server have mysql support.

like image 241
bulicmatko Avatar asked Aug 31 '25 22:08

bulicmatko


2 Answers

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';
like image 182
bcosca Avatar answered Sep 03 '25 12:09

bcosca


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.

like image 21
Valentin Flachsel Avatar answered Sep 03 '25 14:09

Valentin Flachsel