dpli36193 2017-09-28 18:51
浏览 154
已采纳

Fastcgi vs apache连接数据库

I have php with connect to SQL Server.

<?php
$serverName = "AC-CLOUD"; //serverName\instanceName
$connectionInfo = array( "Database"=>"DataSEAS", "UID"=>"sa", "PWD"=>"Masterkey2010", "CharacterSet"  => "UTF-8");
$conn = sqlsrv_connect( $serverName, $connectionInfo);

if( $conn ) {
     echo "Connection established.<br />";
}else{
     echo "Connection could not be established.<br />";
     die( print_r( sqlsrv_errors(), true));
}
?>

$sql = "SELECT sc.Id as Id, sc.Code, sc.Name, sc.Specification, sc.Specification2, sc.X_Specification3, f.Name as firma_Name FROM StoreCards sc
left join firms f on f.id = sc. X_pozicane_u ";

$stmt = sqlsrv_query( $conn, $sql );

if( $stmt === false) {
    die( print_r( sqlsrv_errors(), true) );
}

When I connected it with fastcgi, it is working fine, but now I need to connect it with Apache and it isn't working with this code. When I tried another php code with Apache, or phpinfo, it's working fine, but this connect to db with apache, doesn't work. Can you help me?

  • 写回答

2条回答 默认 最新

  • dqpwdai095465 2017-09-28 22:55
    关注

    Call to undefined function sqlsrv_connect() error means that sqlsrv module hasn't been loaded, you should edit your .ini file and add sqlsrv to the extensions

    This pages shows the example of iis express but you can see how to load sqlsrv dll s in your .ini

    https://www.microsoft.com/en-us/sql-server/developer-get-started/php/windows/step/2.html

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python