dongmengan8620 2017-03-13 16:17
浏览 41
已采纳

无法在PHP中连接到SQL Server

I trying to connect to a MSSQL Server with PHP. For that I am using the following script:

function mssqli_connect($server,$username,$password,$database){
    $connectionInfo = array("Database"=>$database, "UID"=>$username, "PWD"=>$password);
    return sqlsrv_connect($server,$connectionInfo);
}

I am running PHP 7.0.7 on a Windows Server with the IIS 7.5. Unfortunately it doesn't work and I have no idea why.

What I've already tried

I dumped the function, but it only returns bool(false), which is not very helpful. I also tried to ping the server via cmd. This has succeeded. The credentials are also correct.

The extension php_sqlsrv_7_nts.dll is also requested in the php.ini, so it doesn't give me an error, that the function wasn't found.

Do I miss something, which is required?

  • 写回答

1条回答 默认 最新

  • dongyou6795 2017-03-13 16:51
    关注

    I searched again. Now what I found is an other driver software, which is a msi executable file, which installs the odbc driver on the machine.

    https://www.microsoft.com/de-ch/download/details.aspx?id=36434

    I installed that software and now it works without any problems.

    Thanks for all your comments.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 请问一下这个运行结果是怎么来的
  • ¥15 这个复选框什么作用?
  • ¥15 单通道放大电路的工作原理
  • ¥30 YOLO检测微调结果p为1
  • ¥20 求快手直播间榜单匿名采集ID用户名简单能学会的
  • ¥15 DS18B20内部ADC模数转换器
  • ¥15 做个有关计算的小程序
  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下