Trying to get xampp work with MSSQL

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

Trying to get xampp work with MSSQL

Postby n00b0101 » 08. December 2008 17:26

I'm completely new and unfamiliar with mssql, so I'm going to try and describe every little thing here to see if I missed something along the way... At the very end of this file (below the code), I've included the mssql settings from my php.ini file and also some of the sql server 2008 properties that I thought might be relevant.

I have xampp installed on my computer, it has the mssql driver and PEAR::MDB2 installed. extension=php_mssql.dll is uncommented in my php.ini file, as is extension=php_pdo_mssql.dll.

I have Microsoft SQL Server 2008 installed on my computer. I've launched the application (does that mean that the server is running when I do that?), and the username is jadmin and it uses Windows Authentication to connect.

Below is the code that I'm trying to use. I've tried using LPTP, MSSQLSERVER, [ipnumber],1433, [ipnumber.1433], and 127.0.0.1(1434) for the hostname, but no matter what happens, I get MDB2 Error: connect failed.

Please help! This is my first time doing this and I have *no* idea how to use mssql

Also, here's what I get when I do netstat -an, in case it's relevant:
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

Active Connections

Proto Local Address Foreign Address State
TCP 0.0.0.0:80 0.0.0.0:0 LISTENING
TCP 0.0.0.0:135 0.0.0.0:0 LISTENING
TCP 0.0.0.0:443 0.0.0.0:0 LISTENING
TCP 0.0.0.0:445 0.0.0.0:0 LISTENING
TCP 0.0.0.0:2383 0.0.0.0:0 LISTENING
TCP 0.0.0.0:3306 0.0.0.0:0 LISTENING
TCP 0.0.0.0:8080 0.0.0.0:0 LISTENING
TCP 127.0.0.1:80 127.0.0.1:1977 TIME_WAIT
TCP 127.0.0.1:80 127.0.0.1:1981 TIME_WAIT
TCP 127.0.0.1:1028 0.0.0.0:0 LISTENING
TCP 127.0.0.1:1434 0.0.0.0:0 LISTENING

Code: Select all
<?php
   require_once('MDB2.php');
 
   class Database
   {
      private   $_s_username   = '';
      private   $_s_password   = '';
      private   $_s_database   = '';
      private   $_s_server      = '';
      private $_s_type      = '';
      private $_r_connection   = null;
 
      public function __construct($username = null, $password = null, $database = null, $server = null, $type = null)
      {
         try
         {
            if ((strlen($username) == 0)
               || (strlen($password) == 0)
               || (strlen($database) == 0)
               || (strlen($server) == 0))
            {
               $this->_s_username = 'jadmin';
               $this->_s_password = '';
               $this->_s_database = 'testdb';
               $this->_s_server = 'LPTP';
            }
            else
            {
               $this->_s_username = $username;
               $this->_s_password = $password;
               $this->_s_database = $database;
               $this->_s_server = $server;
            }
            if (strlen($type) == 0) {$this->_s_type = 'mssql';}
            else {$this->_s_type = $type;}
         }
         catch(exception $error)
         {
print($error->getMessage());
         }
      }
      
      public function __destruct()
      {
         $this->_r_connection->disconnect();
      }
      
      private function connect()
      {
         try
         {
            $dsn = $this->_s_type . '://' . $this->_s_username . ':' . $this->_s_password . '@' . $this->_s_server . '/' . $this->_s_database;
            $db = MDB2::connect($dsn);
            if (PEAR::isError($db)) {throw new Exception($db->getMessage());}
            else
            {
               $this->_r_connection = $db;
               return true;
            }
         }
         catch(exception $error)
         {
print($error->getMessage());
            return false;
         }
      }
      
      private function disconnect()
      {
         $this->_r_connection->disconnect();
      }
      
      public function query($querystring)
      {
         $r_recordset = null;
         
         try
         {
            $this->connect();
            $r_recordset = $this->_r_connection->query($querystring);
            if (PEAR::isError($r_recordset)) {throw new Exception($r_recordset->getMessage());}
            
            return $r_recordset;
         }
         catch (Exception $error)
         {
print($error->getMessage());
            return false;
         }
         $this->disconnect();
      }
      
      public function execute($query_string)
      {
         $r_result = null;
         $db = null;
         try
         {
            $this->connect();
            $db = $this->_r_connection;
print('<br><br>');
var_dump($db);
print('|');
var_dump($this->_r_connection);
print('<br><br>');
            $r_result = $db->execute($querystring);
            if (PEAR::isError($r_result)) {throw new Exception($r_result->getMessage());}
            
            return $r_result;
         }
         catch (Exception $error)
         {
print("<br>|" . $error->getMessage() . "|");
            return false;
         }
         $this->disconnect();
      }
   }
   
   $db = new Database;
?>


From my php.ini file
-------------------------------------------
[MSSQL]
; Allow or prevent persistent links.
mssql.allow_persistent = On

; Maximum number of persistent links. -1 means no limit.
mssql.max_persistent = -1

; Maximum number of links (persistent+non persistent). -1 means no limit.
mssql.max_links = -1

; Minimum error severity to display.
mssql.min_error_severity = 10

; Minimum message severity to display.
mssql.min_message_severity = 10

; Compatability mode with old versions of PHP 3.0.
mssql.compatability_mode = Off

; Connect timeout
;mssql.connect_timeout = 5

; Query timeout
;mssql.timeout = 60

; Valid range 0 - 2147483647. Default = 4096.
;mssql.textlimit = 4096

; Valid range 0 - 2147483647. Default = 4096.
;mssql.textsize = 4096

; Limits the number of records in each batch. 0 = all records in one batch.
;mssql.batchsize = 0

; Specify how datetime and datetim4 columns are returned
; On => Returns data converted to SQL server settings
; Off => Returns values as YYYY-MM-DD hh:mm:ss
;mssql.datetimeconvert = On

; Use NT authentication when connecting to the server
mssql.secure_connection = Off

; Specify max number of processes. -1 = library default
; msdlib defaults to 25
; FreeTDS defaults to 4096
;mssql.max_procs = -1


SQL SERVER SERVICES
Taken from Sql Server Configuration
-------------------------------------------
Name State Start Mode Log On As Process ID Service Type
SQL Server Integration Services 10.0 Running Automatic NT AUTHORITY\NETWORK SERVICE 1072 SSIS Server
SQL Full-text Filter Daemon Launcher (MSSQLSERVER) Running Manual NT AUTHORITY\LOCAL SERVICE 3708 Full-text Filter Daemon Launcher
SQL Server (MSSQLSERVER) Running Automatic NT AUTHORITY\NETWORK SERVICE 1584 SQL Server
SQL Server Analysis Services (MSSQLSERVER) Running Automatic NT AUTHORITY\NETWORK SERVICE 1532 Analysis Server
SQL Server Reporting Services (MSSQLSERVER) Running Automatic NT AUTHORITY\NETWORK SERVICE 1220 ReportServer
SQL Server Browser Stopped Other (Boot, System, Disabled or Unknown) NT AUTHORITY\LOCAL SERVICE 0 SQL Browser
SQL Server Agent (MSSQLSERVER) Running Manual NT AUTHORITY\NETWORK SERVICE 4712 SQL Agent

SQL SERVER NETWORK CONFIGURATION
Taken from Sql Server Configuration
------------------------------------------
Protocol Name Status
Shared Memory Enabled
Named Pipes Disabled
TCP/IP Enabled
VIA Disabled

SQL NATIVE CLIENT 10.0 CONFIGURATION
Taken from Sql Server Configuration
-------------------------------------------
Name Order Enabled
Shared Memory 1 Enabled
TCP/IP 2 Enabled
Named Pipes 3 Enabled
VIA Disabled


SERVER PROPERTIES
This is taken from "Server Properties" from Microsoft SQL Server Management Studio
--------------------------------------------------------------------------------------
Name LPTP
Product Microsoft SQL Server Enterprise Edition
Operating System Microsoft Windows NT 5.1 (2600)
Platform NT INTEL x86
Version 10.0.1600.22
Language English (United States)
Memory 1271 MB
Processors 1
Root Directory C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL
Server Collation SQL_Latin1_General_CP1_CI_AS
Is Clustered FALSE
n00b0101
 
Posts: 4
Joined: 08. December 2008 17:22

Re: Trying to get xampp work with MSSQL

Postby Wiedmann » 08. December 2008 18:02

get MDB2 Error: connect failed.

IMHO with getDebugInfo() you get a more verbose message as with getMessage().
Wiedmann
AF Moderator
 
Posts: 17102
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Re: Trying to get xampp work with MSSQL

Postby n00b0101 » 08. December 2008 18:46

Thanks. It was actually a problem with the script. After redoing it, I was able to connect successfully.
n00b0101
 
Posts: 4
Joined: 08. December 2008 17:22

Re: Trying to get xampp work with MSSQL

Postby kikz4life » 07. May 2010 10:58

hi there n00b0101,

just want to ask what version of xampp were you using to connect to ms sql 2008? Because i'm unable to connect to ms sql. huhu
kikz4life
 
Posts: 1
Joined: 07. May 2010 10:34


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 98 guests