我有一个用php编写的项目。另外,另一个应用程序用C(sharp)编写,Ms Sql作为数据库引擎。我想从Ms Sql数据库中获取一些数据并在php中使用它。我已尝试在stackover和其他网站上提供了许多解决方案,但似乎没有工作。我正在做的事情,也许有一个地方,我错过了一些东西:
我下载了驱动程序(Ms驱动程序为php)并将其加载到C:\ wamp \ bin \ php \ php5.5.12 \ ext目录。文件是
php_pdo_sqlsrv_55_nts.dll
php_pdo_sqlsrv_55_ts.dll
php_sqlsrv_55_nts.dll
php_sqlsrv_55_ts.dll
通过在扩展区域中包含以下内容来修改php.ini:
extension=php_pdo_sqlsrv_55_nts.dll
extension=php_pdo_sqlsrv_55_ts.dll
extension=php_sqlsrv_55_nts.dll
extension=php_sqlsrv_55_ts.dll
事实上,其中一个网站说我应该通过删除" _55_xx"来重命名,这样它看起来像php_sqlsrv.dll.yet它仍然无法正常工作。
重新启动Apache服务器并发现当您单击wamp监视器时未激活或看到包含的文件,导航到php并查看扩展目录。
我有搜索和搜索,似乎放弃了,但认为最好与可以提供帮助的其他人交流。我目前使用wamp和php版本是php5.5.12。请问,我需要一个解决方案,如何让我的php与Ms Sql服务器连接,并从服务器无缝地获取数据。
答案 0 :(得分:0)
After much surfing the solution to the above question is as follows:
1. If you are using wamp server 64bit, you have to downgrade to wamp32bits.
2. Download the microsoft driver for php, essentially the 3.0 version.
3. Install it to your php extension directory
4. Open the php-ini file and add these two files to the extension section of the file:
extension=php_pdo_sqlsrv_53_ts.dll
extension=php_sqlsrv_53_ts.dll
Also uncomment the extension=php_pdo_mssql.dll for usage.
5. Restart the wamp server to proceed.
6. Test your connection using a blank php file with the following code:
<?php
$serverName = "192.168.1.2"; //serverName\instanceName
$connectionInfo = array( "Database"=>"xxxxxx", "UID"=>"xxxx", "PWD"=>"xxxxx");
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if($conn ) {
//echo "Connection established.<br />";
}else{
echo "Error in connection";
}
?>
NB: You will need to replace xxxx with your credential. You can also use the Wamp Monitor on the desktop to activate any extension file as well.