Unable to connect to SQL Server with PHP

前端 未结 3 1877
粉色の甜心
粉色の甜心 2020-12-17 22:06

Connection to sqlsrv string not working.

$login = new PDO(\"sqlsrv:server=MYSQLSERVER\\SQLEXPRESS;Database=db_name\", \"user\", \"passw\");
         


        
3条回答
  •  余生分开走
    2020-12-17 22:30

    Looks like to connect to MS-SQL, you will need to utilize ODBC.

    Reference:http://php.net/manual/en/pdo.construct.php#120705

    $odbc="odbc:Driver={SQL Server};Server=$server;Database=$database;";
    
    $cnx = new PDO( $odbc , $user, $password);
    

提交回复
热议问题