Mysql Mysqli Programming

Fatal error: Call to undefined function sqlsrv_connect()

Fatal error: Call to undefined function sqlsrv_connect()

There are mostly two php.ini changes files located, in my case, for wamp or xampp server.
One is simple change under the php custom folder changes and the other changes one is in the path of C:\wamp\bin\apache\Apachex.x.x\bin folder.
When connecting to SQL database through sqlsrv_connect used this function,
we are referring to simple the php.ini file in the apache folder.

Add the following php latest version (as per your version) to this file:


PHP Config File Check

Use this simple script to check the your php version:

<?php echo phpinfo(); ?>

Step by Step (call to undefined function sqlsrv_connect() xampp)

Step 1

Also Read :  vuejs crud Insert Update Delete operations Example and demo

Download SQLSRV32.EXE (Microsoft Drivers for PHP for SQL Server) from:

Step 2

Choose path: C:\xampp\php\ext

Step 3

simple Uncomment or Append extension = php_sqlsrv_56_ts.dll in php.ini

Step 4

Last step to Restart Apache from XAMPP or wamp server Control Panel (Stop/Start)

Load the simple PHP drivers in php.ini file and restart the server.


SQL Connection Simple way

$serverName = ", 1433"; //serverName\instanceName, portNumber (default is 1433)
$connectionInfo = array( "Database"=>"pakainfo", "UID"=>"sa", "PWD"=>"[email protected]");
$conn = sqlsrv_connect( $serverName, $connectionInfo);

if( $conn ) {
    // echo "Connection established.<br />";
	echo "<pre>";
     echo "Connection could not be established.<br />";
     die( print_r( sqlsrv_errors(), true));
	 echo "</pre>";


SQL Query

$query="select * from pakainfo where mst_id=1";
$stmt = sqlsrv_query( $conn, $query );
while( $row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_ASSOC) ) {