MySQLi - Server Version



Syntax

string mysqli_get_server_info ( mysqli $link )

Definition and Usage

It returns the version of the MySQL server as an integer.

Example

Try out following example −

<?php
   $servername = "localhost:3306";
   $username = "root";
   $password = "";
   $dbname = "TUTORIALS";
   $conn = new mysqli($servername, $username, $password, $dbname);

   if ($conn->connect_error) {
      die('Connect Error (' . mysqli_connect_errno() . ') '. mysqli_connect_error());
      exit();  
   } 
   if (!mysqli_query($conn, "SET a = 1")) {
      printf("Errorcode: %d\n", mysqli_error($conn));
   }
   echo 'Success... ' . mysqli_get_host_info($conn) . "\n";
   printf("Server version: %d\n", $conn->server_version);
   
   $conn->close();
?>

The sample output of the above code should be like this −

Errorcode: 0 Success... localhost:3306 via TCP/IP Server version: 50505
mysqli_useful_functions.htm
Advertisements