Unable to connect to msSQL database via PHP

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

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



        
9条回答
  •  无人及你
    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.

提交回复
热议问题