简体   繁体   中英

Fatal error: Call to undefined function sqlsrv_connect() in C:\wamp\www\last\connect.php

I am simply trying to connect my php to an microsoft sql server 2005. However, I'm getting this error: Fatal error: Call to undefined function sqlsrv_connect() in C:\\wamp\\www\\last\\connect.php

My code is simply:

<?php
$serverName = "OurIPAddress"; //serverName\instanceName, portNumber (default is 1433)
$connectionInfo = array( "Database"=>"Thenameofourdatabase", "UID"=>"OurID", "PWD"=>"Ourpassword");
$conn = sqlsrv_connect( $serverName, $connectionInfo);

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

I installed microsoft driver 3.0 from this link Microsoft driver 3.0 and edited the php.ini file from the apache server with extension=c:/wamp/bin/php/php5.5.12/ext/php_sqlsrv_53_ts.dll.

Following the instructions carefully the sqlsrverconnectdriver doesn't show on php_info()

PS I followed this links: Question 1 Question 2 Question 3

First, you must use a driver that match your PHP version and in your case is Microsoft Drivers 3.1 for PHP for SQL Server for your PHP 5.5. Extract the php_sqlsrv_55_ts.dll , or php_pdo_sqlsrv_55_ts.dll to the ext folder, and set the php.ini .

Then install the Microsoft ODBC Driver 11 for SQL Server .

Notice : that the drivers only work for WAMP 32 bit and you can download it here , even if you use the 64 bit OS version.

I've try many time to use the driver on WAMP 64bit with no luck. If you still got the error, you can share the log in c:/wamp/logs/php_error.log here. Maybe I or someone else can help you more.

You should download Microsoft Drivers 3.1 for PHP for SQL Server if your PHP version is 5.5 or later.

However, version 3.1 requires SQL Server 2008 and later.

More information and download link: http://www.microsoft.com/en-us/download/details.aspx?id=20098

If You have this problem

Fatal error: Call to undefined function ocilogon()

You will go in the folder C:/wamp/bin/apache/apache2.4/bin/php.ini and you will discomment (;) in the line extension which have oci.

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