douhun8647 2013-04-11 08:53 采纳率: 0%
浏览 83
已采纳

无法连接到Microsoft SQL Server

I'm trying to connect a php script to a Microsoft SQL Server, Additionally I'm doing some testing on my own to learn more about php and servers.

if(function_exists("sqlsrv_connect"))
{
    echo "exists<br/>";
}else
{
    die("does not exist<br/>");
}
$serverName = "myTestServer";
$connectionInfo = array( "Database"=>"test_name", "UID"=>"testUser", "PWD"=>"testPwd");
$conn = sqlsrv_connect($serverName, $connectionInfo);
if($conn)
{
    echo "sucessful";
}
else
{
    echo "failed ";
}

The output is:

exists
failed

Therefore I can see that the .dll was installed as intended. Am I missing something else? or could this be a problem in the server properties?

  • 写回答

1条回答 默认 最新

  • dongyuan9109 2013-04-11 09:31
    关注

    Whenever a failure occurs with a SQLSRV PHP function, call sqlsrv_errors to find out the root cause. In your case, it seems you don't have the correct SQL Server ODBC drivers installed on the PHP server. Install the drivers as recommended by your error message, and things should improve.

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

报告相同问题?

悬赏问题

  • ¥15 TLS1.2协议通信解密
  • ¥40 图书信息管理系统程序编写
  • ¥20 Qcustomplot缩小曲线形状问题
  • ¥15 企业资源规划ERP沙盘模拟
  • ¥15 树莓派控制机械臂传输命令报错,显示摄像头不存在
  • ¥15 前端echarts坐标轴问题
  • ¥15 ad5933的I2C
  • ¥15 请问RTX4060的笔记本电脑可以训练yolov5模型吗?
  • ¥15 数学建模求思路及代码
  • ¥50 silvaco GaN HEMT有栅极场板的击穿电压仿真问题