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

Problems with the Windows version of XAMPP, questions, comments, and anything related.

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

Postby WolfShade » 08. December 2011 21:23

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,

^_^
Last edited by WolfShade on 13. December 2011 18:40, edited 1 time in total.
WolfShade
 
Posts: 15
Joined: 30. November 2011 02:08
Operating System: Windows XP / SP3 | Apache 2.2

Re: MS-SQL 2008 R2 not working with XAMPP

Postby WolfShade » 10. December 2011 02:12

Has anyone experienced the same issue with M$ SQL Server 2008 R2?

^_^
WolfShade
 
Posts: 15
Joined: 30. November 2011 02:08
Operating System: Windows XP / SP3 | Apache 2.2

Re: MS-SQL 2008 R2 not working with XAMPP

Postby WolfShade » 13. December 2011 18:35

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.

^_^
WolfShade
 
Posts: 15
Joined: 30. November 2011 02:08
Operating System: Windows XP / SP3 | Apache 2.2

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

Postby Sharley » 13. December 2011 23:49

Thanks for your feedback and I am sure your posts will help others with a similar problem.

Best wishes. :)
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 41 guests