PHP MySql Server Version


 

PHP MySql Server Version

PHP MySql Server Version tutorial provides an example through which you can get the MySql server version.

PHP MySql Server Version tutorial provides an example through which you can get the MySql server version.

PHP MYSQL server version

Sometimes we need to check the version of MySql, PHP provides mysql_get_server_info() function to check the MySql version.

To check the version of MySql we need to know username (such as: root) and password (whatever you have set during the installation process.)

If you are interested to know in detail about the die construct please visit our web page: http://www.roseindia.net/sql/mysql-example/php-sql-die.shtml

Code:

<?php

$link = mysql_connect('localhost', 'root',  ' zz ' );//mysql_connect(): it open a connection to a MySql server

//root is the name of user and password is zz, replace these values with your MySql's username & respective password

if (!$link) {

die('Could not connect: ' . mysql_error());//mysql_error() function returns the text of the error message

// die construct is equivalent to exit()

}

printf("MySQL server version: %s\n", mysql_get_server_info());//mysql_get_server_info() is used to get MySql server information

?>

Output:

MySQL server version: 5.0.19-nt

Ads