简体   繁体   中英

How to connect sql server with php using xampp?

I am trying to connect my SQL server with PHP using Xampp. I have already uploaded dll files in the ext folder but I am unable to connect it. My PHP version is 7.2.6. Uploaded dll files are - php_pdo_sqlsrv_72_ts.dll, php_sqlsrv_72_ts.dll. I have written this code to connect my SQL database with PHP-

I am trying to connect my SQL server with PHP using Xampp. I have already uploaded dll files in the ext folder but I am unable to connect it. My PHP version is 7.2.6. Uploaded dll files are - php_pdo_sqlsrv_72_ts.dll, php_sqlsrv_72_ts.dll. I have written this code to connect my SQL database with PHP-

 <?php $serverName = "INDO-SERV\\SQLEXPRESS,1443"; $uid = "sa"; $pwd = "XXXXXX"; $databaseName = "web"; $connectionInfo = array("UID" => $uid, "PWD" => $pwd, "Database"=>$databaseName); $conn = sqlsrv_connect( $serverName, $connectionInfo); if( $conn ) { echo "Connection established.\\n"; } else { echo "Connection could not be established.\\n"; die( print_r( sqlsrv_errors(), true)); } sqlsrv_close( $conn); ?>

I am getting this error when I had tried this-

Fatal error: Uncaught Error: Call to undefined function sqlsrv_connect() in C:\\xampp\\htdocs\\biometric\\db.php:7 Stack trace: #0 {main} thrown in C:\\xampp\\htdocs\\biometric\\db.php on line 7.

Anyone has an idea where I am doing wrong or how to connect with the database.

I am trying to connect my SQL server with PHP using Xampp. I have already uploaded dll files in the ext folder but I am unable to connect it. My PHP version is 7.2.6. Uploaded dll files are - php_pdo_sqlsrv_72_ts.dll, php_sqlsrv_72_ts.dll. I have written this code to connect my SQL database with PHP-

 <?php $serverName = "INDO-SERV\\SQLEXPRESS,1443"; $uid = "sa"; $pwd = "XXXXXX"; $databaseName = "web"; $connectionInfo = array("UID" => $uid, "PWD" => $pwd, "Database"=>$databaseName); $conn = sqlsrv_connect( $serverName, $connectionInfo); if( $conn ) { echo "Connection established.\\n"; } else { echo "Connection could not be established.\\n"; die( print_r( sqlsrv_errors(), true)); } sqlsrv_close( $conn); ?>

I am getting this error when I had tried this-

Fatal error: Uncaught Error: Call to undefined function sqlsrv_connect() in C:\\xampp\\htdocs\\biometric\\db.php:7 Stack trace: #0 {main} thrown in C:\\xampp\\htdocs\\biometric\\db.php on line 7.

Anyone has an idea where I am doing wrong or how to connect with the database.

Download driver from:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM