I have MSSQL Server 2008, MS WINDOWS SERVER 2008 RC2 AND PHP 5.4
php.info have rows
[PHP_PDO_SQLSRV_54_NTS]
extension=php_pdo_sqlsrv_54_nts.dll
[PHP_PDO_ODBC]
extension=php_pdo_odbc.dll
[PHP_SYBASE_CT]
extension=php_sybase_ct.dll
[PHP_SQLSRV_54_NTS]
extension=php_sqlsrv_54_nts.dll
Php info found here http://89.111.180.28/index.php
i see lines with Extensions php.ini but i dont see lines with extensions SQLSRV in php.info...
for connect to MSSQL SERVER i use script
$conn_array = array (
"UID" => "user",
"PWD" => "passw",
"Database" => "database",
"Encrypt" => 1,
"TrustServerCertificate" => 1) ;
$conn2 = sqlsrv_connect('localhost' , $conn_array);
if ($conn2)
{
echo 'MSSQL Connection successful';
}
else
{
die( print_r( sqlsrv_errors(), true));
}
sqlsrv_close( $conn2 );
But i see error:
Fatal error: Call to undefined function sqlsrv_connect() in C:\inetpub\wwwroot\89.111.180.28\index.php on line 18
Tell me please why i have error and how make the right ?
p.s.: server already was restarted.
I just had this problem myself. I finally got it fixed, so I figured I'd share.
The problem was that, although I had the sqlsrv dll installed (copied to my php/ext folder), and I had it added in my php.ini, in IIS, it was 'disabled'.
Here's some step by step instructions, in case anyone has this same problem again. (Or for future reference for me :))
Download (and install) the SQL Server drivers (.dll)
php -i | more
, and look for the line extension_dir
. (For me it was on the fourth press of more
). Alternately, make a simple php file containing only <?php phpinfo(); ?>
, and run it in the browser. This will give the same information, but in a much easier-to-read format.Add the extension to your php.ini
php -i | more
again, looking for Loaded Configuration File
, or check that simple php script again (I highly recommend you make it - it'll save you time and effort). The path you find there is the file you need to edit.Add the following lines to your php.ini, and save it:
[PHP_SQLSRV]
extention=php_sqlsrv_56_nts.dll
Enable the extension in IIS Manager
IIS Manager
, and press enter.PHP Manager
PHP Extensions
, click Enable or Disable an Extension
.Enabled
, look under Disabled
for it. When you find it, right-click on it, and click Enable
in the context menu that appears.Test to make sure it worked
phpinfo()
page you made (you did, didn't you?), and look under Registered PHP Streams
. If you see sqlsrv
in that list, you're set!If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With