none
HELP ME PLS MS SQL SERV 2005

    Question

  •  

    I can't connect to MSSQL SERVER 2005.

     

    i create PHP script

     

    <?php

    class DB {
    var $host='10.1.223.109';
    var $database="Credit";
    var $name='SA';
    var $password='125';
    var $link;


    function __construct()
    {
    $this->link = sqlsrv_connect($this->host,

    array('UID'=>$this->name,'PWD'->$this->password,'Database'->$this->database));

    ($this->link)?(echo "Succesfull") : (echo "Failed")
    }

    function __destruct()
    {
    sqlsrv_close($this->link);
    }

    };

    ?>

     

     

    and script print Failed. Why?

    Thursday, August 07, 2008 9:17 AM

Answers

All replies

  • What is the error message you are getting??

    What is the edition of SQL Server you are using??

     

    I'm not sure about PHP connection string, check the below article.

    http://www.webcheatsheet.com/PHP/connect_mssql_database.php &

    http://www.phpbuilder.com/columns/alberto20000919.php3

    Thursday, August 07, 2008 10:16 AM
    Moderator
  • I use MSSQL SERVER 2005. standart function PHP 5.2.6 mssql_connect can't connect to MSSQL SERVER 2005. function sqlsrv_connect too can't connect or i use mistakes 

     

    Thursday, August 07, 2008 10:29 AM
  • Have you tried the examples given in the link above?

    Thursday, August 07, 2008 10:37 AM
    Moderator
  • YES.
    No results, as I understand it is for examples for MSSQL 2000

     

    Thursday, August 07, 2008 11:39 AM
  •  

    I modify this script

    <?php

    class DB {
    var $host='10.1.223.109';
    var $database="Credit";
    var $name='SA';
    var $password='125';
    var $link;


    function __construct()
    {
    $this->link = sqlsrv_connect($this->host,array('UID'=>$this->name,'PWD'=>$this->password,'Database'=>$this->database);

    if (!$this->link)

    {

    print_r (sqlsrv_errors());

    }

    }

    function __destruct()
    {
    sqlsrv_close($this->link);
    }

    };

    ?>

     

    and script print Array ( [0] => Array ( [0] => IM002 [SQLSTATE] => IM002 [1] => 0 [code] => 0 [2] => [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified [message] => [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified ) )

    Thursday, August 07, 2008 11:57 AM
  • Loviorov-

     

    Please see my response in this thread: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=3707453&SiteID=1

    I think my answer there will fix your problem.

     

    Let us know if that doesn't help.

     

    -Brian

     

    Thursday, August 07, 2008 5:42 PM
    Moderator
  • I am running through this problem also.  I don't believe it is the PHP code however,

    Microsoft has released a SQL Server 2005 driver for PHP  that can be found here -  http://www.microsoft.com/downloads/details.aspx?FamilyId=61BF87E0-D031-466B-B09A-6597C21A2E2A&displaylang=en

    This helps bridge IIS - PHP - MSSQL 2005
    Wednesday, August 13, 2008 5:21 PM