how to get mysql version

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Nay
Forum Regular
Posts: 951
Joined: Fri Jun 20, 2003 11:03 am
Location: Brisbane, Australia

how to get mysql version

Post by Nay »

Hey, how do i find the mysql version on the server?

I'm trying to make a report thinggy. so far i've been able to track down the php version with

phpversion();

any idea?

thanks...

-Nay
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

haven't tested this but

Code: Select all

// returns a string with the current mySQL version connecting handled by $dbh. 
$mysqlver = pos(mysql_fetch_row(mysql_query("SELECT VERSION()",$dbh)));
Mark
Nay
Forum Regular
Posts: 951
Joined: Fri Jun 20, 2003 11:03 am
Location: Brisbane, Australia

Post by Nay »

thanks for the code, i tried it out as:

Code: Select all

<?

$connection = mysql_connect('localhost','Nay', 'xxxxxxxxxxx');

$dbh = mysql_select_db('news',$connection);

$mysqlver = pos(mysql_fetch_row(mysql_query("SELECT VERSION()",$dbh)));

echo $mysqlver;

?>
result:

Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in c:\appserv\www\sqlver.php on line 7

Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in c:\appserv\www\sqlver.php on line 7

Warning: pos(): Passed variable is not an array or object in c:\appserv\www\sqlver.php on line 7

any ideas?

-Nay
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

I did it like this...

Code: Select all

$connection = mysql_connect('host', 'user', 'pass'); 
$result = mysql_query("select version()");
$mysqlver = mysql_result($result,0); 
echo $mysqlver;
User avatar
kendall
Forum Regular
Posts: 852
Joined: Tue Jul 30, 2002 10:21 am
Location: Trinidad, West Indies
Contact:

Post by kendall »

Ha,

Always wanted to know how to do this...thanks JAM

Kendall
Nay
Forum Regular
Posts: 951
Joined: Fri Jun 20, 2003 11:03 am
Location: Brisbane, Australia

Post by Nay »

Thanks again JAM.........

-Nay
Post Reply