Reputation: 81
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()
P.S I followed this links: Question 1 Question 2 Question 3
Upvotes: 1
Views: 7754
Reputation: 1
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.
Upvotes: 0
Reputation: 109
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.
Upvotes: 1
Reputation: 2459
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
Upvotes: 0