Unable to connect to msSQL database via PHP

前端 未结 9 381
余生分开走
余生分开走 2021-01-13 07:30

I am using the current code in attempt to access a msSQL 2005 db:



        
相关标签:
9条回答
  • 2021-01-13 08:09

    It sounds to me like one of your DLLs is the wrong version. There was an issue of some sort with the move from SQL2000 to SQL2005 that the creators of PHP didn't resolve themselves. There are a variety of posts about it here: the following link

    I believe the DLL is ntwdblib.dll and the version needs to be version 2000.80.194.0 at the very least. If you're running Apache or WampServer, there is an identical dll where the Apache DLLs are stored that needs to be overwritten.

    Note: I was having this issue a few days ago and finding the correct DLLs and overwriting both allowed it to work.

    Also: You may need to setup remote connections. Sql Server 2005 has remote connections disabled by default. You can allow remote connections by running the SQL Surface Area Configuration utility.

    0 讨论(0)
  • 2021-01-13 08:09

    if you using windows 10.

    step 1. click start button

    step 2. type Service and enter (open App Services)

    step 3. find - SQL Server (MSSQLSERVER)

    step 4. Right click ->select Properties

    step 5. show popup. you select 2nd tab (Log On)

    step 6. select local system account

    step 7. and check allow service to interact with desktop

    step 8. finally click ok.

    1 time refresh now connected. I hope it's very useful

    0 讨论(0)
  • 2021-01-13 08:10

    Try calling mssql_get_last_message() to get the last error message:

    $dbhandle = mssql_connect($myServer, $myUser, $myPass)
      or die("Couldn't connect to SQL Server on $myServer. Error: " . mssql_get_last_message());
    
    0 讨论(0)
  • 2021-01-13 08:13

    Invalid credentials, if your not using localhost be sure you add the server's ip to the safe list.

    0 讨论(0)
  • 2021-01-13 08:15

    First try to do something like phpinfo() on your browser, than see which databases are allowed.

    If you don't see anything like mssql then it is not configured. So use the odbc_connect() which will be configured...your connection string will be like this:

    $server = '';
    $user = '';
    $password = '';
    $database = '';
    $connection = odbc_connect("Driver={SQL Server Native Client `11.0};Server=$server;Database=$database;", $user, $password);`
    

    If you are using mssql 2005 or 2008, then change d 11.0 to 10.0 and for other versions just change to the version of your mssql.

    0 讨论(0)
  • 2021-01-13 08:17

    Download the driver in this site http://www.microsoft.com/en-us/download/details.aspx?id=20098, then open your php.ini file and add the DLL that you download.

    0 讨论(0)
提交回复
热议问题