Error connecting to MSSQL with SQLSrv and PHP 5.4.7

前端 未结 2 1131
南笙
南笙 2021-01-21 18:51

I\'m trying to connect to an MSSQL database with PHP and encounter a very frustrating error while trying to connect. It loads for a minute, before printing out the following mes

2条回答
  •  灰色年华
    2021-01-21 19:27

    My install process actually worked, but the connection was indeed invalid. I should have been using the IP address as the host name, which I was not. I was also using a colon instead of a comma before the port number. Finally, no spaces can be allowed in the connection string, which I thought would be automatically stripped out. So, here's a valid connection string for those of you that may find yourself in a similar predicament:

    $connectionString="sqlsrv:Server=123.123.12.1,9864;Database=mssqldatabaseWootWoot";
    

    Also, in response to my earlier observation about that function sqlsrv_connect, I had not enabled the driver necessary for that function. It is located in php_sqlsrv_54_ts.dll, which after enabling, reported the function as existing.

    Thanks to anyone who put any time into solving this.

提交回复
热议问题