Jump to content

PHP shows the sqlsrv drivers, but I can't connect to MS-SQL


sql-lover

Recommended Posts

Ok,

 

I managed to install PHP and Apache on a virtual machine at home (host runs Windows 2008 Server). I'm half way testing there but I need to start working on my work's laptop now (for presentation, official stuff, etc)

 

So I installed XAMPP. I downloaded the MS-SQL drivers from this URL: http://msdn.microsoft.com/library/cc296170.aspx

 

I edited PHP ini adding this line:

 

extension=php_sqlsrv_53_ts_vc9.dll

 

And also dropped the php_sqlsrv_53_ts_vc9.dll file into the "ext" folder that goes under xampp

 

I restarted Apache and I can see PHP shows the sqlsrv drivers section, so should work ok, but I can't connect to MS-SQL. I can't even run a simple PHP script like this:

 

 

<?php
$serverName = "servername";
$connectionOptions = array("Database"=>"AdventureWorks");
$conn = sqlsrv_connect( $serverName, $connectionOptions);
if( $conn === false )
die( FormatErrors( sqlsrv_errors() ) );
?>

 

It fails miserably with following error: Fatal error: Call to undefined function FormatErrors() in C:\xampp\htdocs\project\connectivity.php on line 6

 

Am I missing something? By the way, my work's laptop runs Windows Vista. Not sure if that can be a problem. I am running most recent SQL client drivers I think.

Link to comment
Share on other sites

FormatErrors is not any standard function.  Not sure where you got that name from.    To see what the error is, try

var_dump(sqlsrv_errors());

 

Thanks for reply.

 

I will check at home, but I'm almost sure the code there works! and uses that function.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.