Page 1 of 1

MS-SQL 2008 R2 not working with XAMPP 1.7.7 [SOLVED]

PostPosted: 08. December 2011 21:23
by WolfShade
I noticed that someone else had issues with getting XAMPP to work with MS-SQL Server 2005 (http://community.apachefriends.org/f/viewtopic.php?f=16&t=49124). I followed that thread with interest, as I'm unable to get XAMPP to work with my MS-SQL Server 2008 R2, even after I followed the same instructions.

As of right now, I do not have the code set up to give me a specific reason for the error; just a simple JavaScript alert saying whether it works or not.

Here is the code that is not working. Any suggestions would be greatly appreciated.

Code: Select all
      $conn = mssql_connect( 'STONEHENGE\MSSQLSERVER', 'username', 'password');
      if( $conn ) {
          $statusMsg= "Database connection works.";
      }else{
          $statusMsg= "Database connection is NOT working.";
      }

Thanks,

^_^

Re: MS-SQL 2008 R2 not working with XAMPP

PostPosted: 10. December 2011 02:12
by WolfShade
Has anyone experienced the same issue with M$ SQL Server 2008 R2?

^_^

Re: MS-SQL 2008 R2 not working with XAMPP

PostPosted: 13. December 2011 18:35
by WolfShade
I finally got it working.

First, I downloaded the SQL Server 2008 R2 Drivers for PHP located here. I followed the instructions to extract the files directly into my /xampp/php/ext folder, and modified my php.ini file to include the extension I needed.

Then I modified my code as follows, using sqlsrv_connect, instead of mssql_connect:
Code: Select all
$sName = "MYSERVER,1433\MYINSTANCE"; //I include the port after a comma in the server name.
$cInfo = array("Database"=>"FirstTest", "UID"=>"myUser", "PWD"=>"myPassword");
$conn = sqlsrv_connect($sName, $cInfo);
if($conn) {
    $notNice = "Database connection works."; // If $notNice exists, I use JavaScript to show an alert.
    sqlsrv_close($conn);
}else{
    $notNice = "Database connection is NOT working.";
    die(print_r(sqlsrv_errors(), true));
}

And it now works. :) This can be marked SOLVED. I looked for a way to do it, myself, and can't find it.

^_^

Re: MS-SQL 2008 R2 not working with XAMPP 1.7.7 [SOLVED]

PostPosted: 13. December 2011 23:49
by Sharley
Thanks for your feedback and I am sure your posts will help others with a similar problem.

Best wishes. :)