php sql server 配置运行
发布时间:2020-12-13 17:31:57 所属栏目:PHP教程 来源:网络整理
导读:1. 下载sqlserver扩展 https://www.microsoft.com/en-us/download/details.aspx?id=20098 解压到 phpStudyPHPTutorialphpphp-7.2.1-ntsext ? ?php.int extension=php_pdo_sqlsrv_72_nts_x64.dll extension=php_sqlsrv_72_nts_x64.dll 安装 msodbcsql.ms
1.下载sqlserver扩展 https://www.microsoft.com/en-us/download/details.aspx?id=20098 解压到 phpStudyPHPTutorialphpphp-7.2.1-ntsext ? ?php.int
安装 msodbcsql.msi? 不然报错 This extension requires the Microsoft ODBC Driver for SQL Server. Access the following URL to download the ODBC Driver for SQL Server for x64 ? 代码:sqlcon.php $serverName = "localhost"; $connectionInfo = array( "Database"=>"DBWMS","UID"=>"sa","PWD"=>"123123"); $conn = sqlsrv_connect( $serverName,$connectionInfo ); if( $conn === false ) { die( print_r( sqlsrv_errors(),true)); } if( $conn === false ) { echo "Unable to connect."; die(var_dump(sqlsrv_errors(),true)); } header("Content-type: text/html; charset=utf-8"); include "sqlcon.php"; $order = $_POST[‘OrderNum‘]; //$order = "TY20171121103652803442"; $sql = "SELECT ID,ExpressNum,OrderNum,NetWeight,GrossWeight FROM dbo.St_UserOrder where OrderNum= ‘{$order}‘"; $stmt = sqlsrv_query( $conn,$sql ); $stmt = sqlsrv_fetch_array($stmt); echo json_encode($stmt); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |