Page 1 of 1

how to get mysql version

Posted: Mon Sep 08, 2003 7:48 am
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

Posted: Mon Sep 08, 2003 7:54 am
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

Posted: Mon Sep 08, 2003 8:18 am
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

Posted: Mon Sep 08, 2003 8:43 am
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;

Posted: Mon Sep 08, 2003 9:21 am
by kendall
Ha,

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

Kendall

Posted: Mon Sep 08, 2003 10:06 am
by Nay
Thanks again JAM.........

-Nay