Page 1 of 1
Check Mysql Info using PHP code
Posted: Sun Jan 13, 2008 6:36 pm
by it2051229
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??
Re: Check Mysql Info using PHP code
Posted: Sun Jan 13, 2008 8:06 pm
by Ollie Saunders
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');
}
Edit: file_get_content
s
Re: Check Mysql Info using PHP code
Posted: Tue Jan 15, 2008 5:02 pm
by it2051229
THANK YOU!
Re: Check Mysql Info using PHP code
Posted: Fri Jan 18, 2008 9:43 am
by strider72
On line 2 of your code:
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
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....)
Re: Check Mysql Info using PHP code
Posted: Fri Jan 18, 2008 10:43 am
by Ollie Saunders
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.
Re: Check Mysql Info using PHP code
Posted: Wed Jan 23, 2008 10:20 am
by strider72
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.
