PHP ERROR "Uncaught Error: Call to Undefined Function sqlsrv_connect()" when connecting

Asked

Viewed 1,348 times

0

Good evening, I am developing a PHP application using SQL Server but I am not able to make the connection with the database. I already downloaded the driver, I’ve put the dlls in the ini of PHP, I’ve downloaded ODBC, I’ve directed the folder in ini, I’ve tried several encodings and all result in the same error. I have a short deadline and I’m unable to connect, could someone please help me?

I’m using SQL2012, PHP 43 SQLSRV driver with xampp, PHP 7.1.9

This is the code:

<?php

// Dados do banco
$dbhost   = "nomedomeuddns.ddns.net\INSTANCIA,8091";   #Nome do host
$db       = "IntegracaoDB";   #Nome do banco de dados
$user     = "sa"; #Nome do usuário
$password = "Senha123";   #Senha do usuário

$conninfo = array("Database" => $db, "UID" => $user, "PWD" => $password);
$conn = sqlsrv_connect($dbhost, $conninfo);



?>
  • Enable the SQL Server extension on your php.ini correct. Use <?php phpinfo(); and look for php.ini to check the correct file and then restart the web server

  • I did it, really wrong.

1 answer

0

I know it has been a while since it was posted and answered, however I came across this problem currently and managed to solve. I checked in the most diverse forums and tutorials and in none did I notice the mention. The solution I found for this problem involving the sql server driver for php (7.4 ) which was in the lines I added to php.ini had to put beyond the file name (Extension=php_pdo_sqlsrv_74_ts_x64.dll Extension=php_sqlsrv_74_ts_x64.dll), also the extension ". dll" and after restarting the xampp everything worked perfectly. abs.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.