Problem with connection between sqlsrv_connect with php script
-
my PC is 64bit, i want to make connection between microsoft sqlserver 2014 with php script, it always show fatal error in sqlsrv_connect even i have copied all extensions pdo_sqlsrv_56.dll with thread safe and not in my php/ext folder but it cannot solve it. Why?
-
Please use 32 bit dll. I will update 64 bit soon
-
so i must use all .dll of 32bit even if my PC is 64bit, isn't it? i have tried it but it still says fatal error or show nothing when i type localhost/phpmyadmin
-
Yes, Laragon bundles 32-bit version of PHP for portability, so you must use 32-bit thread safe extensions. Please check error logs to figure out, google it. I hope you will sort it out. If not, I will help you when I'm back from vacation.
-
@salma-nabila :
After downloading Microsoft drivers 3.2 (https://www.microsoft.com/en-us/download/details.aspx?id=20098), and extracting them, please take note of 2 files:- php_sqlsrv_56_ts.dll
- php_pdo_sqlsrv_56_ts.dll
Copy the two to ext dir, then go to Menu > PHP > Extensions and click to the dll names to enable them.
That's all. No need to restart Apache or do something else.
To test if it works:
Use phpinfo() and search: sqlsrv
You will see:
-
I´m desperate, , I´m with this error, changed from wamp (that was working fine ) to laragon, but SQLSRV don´t work for nothing ! Somebody can help me ?
-
@cassolatto : Did you follow this tutorial:
https://forum.laragon.org/topic/104/tutorial-how-to-add-php-extensions-to-laragon-ex-microsoft-sql-serverAlso, please use the same version of Apache/PHP like WAMP to make sure of compatability:
https://forum.laragon.org/topic/166/tutorial-how-to-add-another-php-version
-
Hi there, thansk for the response, a few explanation:
the dll of my wamp , I saved, was : php_pdo_sqlsrv_7_ts_x64.dll
The code I use to conenct in php is :
/* TSQL Query */
$sql_exp = " SELECT * FROM SZG010 WITH (NOLOCK) WHERE ZG_LIBEROU='' AND SZG010.D_E_L_E_T_='' ORDER BY ZG_DATA , ZG_HORA ";
//file_put_contents("LOG_wsbLERAPROVACOESABERTAS.log", 'sql:'.$sql_exp."\r\n" );
$tsql = $sql_exp;
$stmt = sqlsrv_query( $conn, $tsql);What is wrog ? I followed the tutorial as well, then all the tips to "correct" but Always says that php7.dll is missing or something like this !
Thank you so much in advance !
-
@cassolatto : If you check phpinfo() and see the extension displayed, can you show the real error message?
-
-
Fatal error: Uncaught Error: Call to undefined function sqlsrv_connect() in C:\laragon\www\wsb\wsb_ler_aprovador.php:23 Stack trace: #0 {main} thrown in C:\laragon\www\wsb\wsb_ler_aprovador.php on line 23
-
@cassolatto : How about your phpinfo()?
-
It don´t show it ! I´m desperate because my webservices are down !
-
-
I´ve installed odbc driver version 17 , by the way , still not working !
-
@cassolatto : Please check:
- Download the drivers - in your case (php-7.2.19-Win32-VC15-x64) Thread Safe:
- SQLSRV: https://windows.php.net/downloads/pecl/releases/sqlsrv/5.8.1/php_sqlsrv-5.8.1-7.2-ts-vc15-x64.zip
- PDO_SQLSRV: https://windows.php.net/downloads/pecl/releases/pdo_sqlsrv/5.8.1/php_pdo_sqlsrv-5.8.1-7.2-ts-vc15-x64.zip
- Extract the .dlls to
ext
dir:
- php_sqlsrv.dll
- php_pdo_sqlsrv.dll
The dir in your case is:
C:/laragon/bin/php/php-7.2.19-Win32-VC15-x64/ext
From your images, the name of the dlls are different (sqlsrv_56_ts
) so I guess you downloaded wrong packages.
-
First, thank you so much, second I´ll do it now and give you a response
-
THANK YOU VERY MUCH !
It´s working fine ! ! ! ! !
God Bless You !
-
@cassolatto : I'm glad to hear that
Cheers!
-
Really, Laragon is so SUPERIOR in comparison with WAMP, fast, so fast and not a Memory eater !
So cool !
Merci !