Ok, how do I check mysql Version and other infos without using the code phpinfo();
I'm trying to make a pre-installation check for my project and it requires MySQl, Enabled GD Library, and PHP version 4.3 and above.. how do I do that??
Check Mysql Info using PHP code
Moderator: General Moderators
- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
Re: Check Mysql Info using PHP code
Code: Select all
if ($result = mysql_query('SELECT VERSION()')) {
$mysqlVersion = mysql_fetch_object($result);
}
$gdInfo = gd_info();
$gdVersion = $gdInfo['GD Version'];
$phpVersion = PHP_VERSION;
if (stripos(PHP_OS, 'Linux') !== false && file_exists('/etc/issue.net')) {
$osVersion = file_get_contents('/etc/issue.net');
}
Last edited by Ollie Saunders on Tue Jan 15, 2008 5:14 pm, edited 1 time in total.
Re: Check Mysql Info using PHP code
THANK YOU!
Re: Check Mysql Info using PHP code
On line 2 of your code:
Any thoughts? This is (by necessity) running a version check _before_ we've connected to the database, which may be the problem. If so, I'm trying to figure out how to check version before connecting....
(The script in question returns diagnostic info in case of a problem -- so by definition it may run before a connection is made....)
Code: Select all
PHP Parse error: syntax error, unexpected T_STRING in /Users/Steve/public_html/wp-content/multiblog/mb-functions.php on line 146(The script in question returns diagnostic info in case of a problem -- so by definition it may run before a connection is made....)
- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
Re: Check Mysql Info using PHP code
In my code the version is retrieved by a query. You can't query a database without a connection to it. Here's another way you can do it:
This method assumes you have permission to call shell_exec() and that the mysql binary you wish to enquire about is in the system $PATH. You'll need to process $version a bit to get the actual version. Remember to use version_compare() for any conditional logic involving versions that I suspect you will be doing.
Code: Select all
$version = `mysql -V`Re: Check Mysql Info using PHP code
Thanks for the assist, but no go. This is actually for a diagnostic "help" screen in a software plugin I'm trying to make. As it will be distributed, I can't assume shell access.
Not that important. I'm throwing in an "if" clause and return "not available" if another method doesn't work....
Thanks though.
Not that important. I'm throwing in an "if" clause and return "not available" if another method doesn't work....
Thanks though.