How can I do that? like:
if (mysql is available) {
connect and do queries
}
else {
use files
}
Just try to connect and if fail then do other thing.
eg:
if ($link = mysql_connect('localhost', 'mysql_user', 'mysql_password')) {
//do queries
} else {
//use files
}
I can't test this, but
if (function_exists('mysql_connect'))
may work.
Or use the phpinfo() function and search "mysql" with CTRL+F and check if the extension is activated...
Not that elegant:
if (shell_exec('mysql -V') != ''){
echo "MySql is here";
}else{
echo "No MySql here";
}
You may search for mysql in the string that "shell_exec('mysql -V')" will return.