【发布时间】:2014-05-10 05:40:20
【问题描述】:
我安装的驱动程序有问题,因此我的 MSSQL 可以与 PHP 并行运行...
我在 PHP 的目录文件中放置了以下驱动程序,并编辑了它的 .ini 文件:
- php_sqlsrv_54_ts.dll
- php_pdo_sqlsrv_54_ts.dll
我收到以下错误消息:
PHP Startup: Unable to load dynamic library 'c:/wamp/bin/php/php5.4.12/ext/php_sqlsrv_54_ts.dll' - %1 is not a valid Win32 application.PHP Startup: Unable to load dynamic library 'c:/wamp/bin/php/php5.4.12/ext/php_pdo_sqlsrv_54_ts.dll' - %1 is not a valid Win32 application.
我有以下关于我的 PHP 和 MSSQL 的信息:
对于 PHP:
- PHP 版本 5.4.12
- 通过 WAMP SERVER 安装 PHP
- 架构 x64
- 启用线程安全
对于 MSSQL:
- MSSQL 2014 速成版
- 我正在使用 Microsoft SQL Server Management Studio 来管理数据库
这些都是以下信息...我在这里搞砸了吗?请帮助我,我还是 PHP 的新手,尤其是 MSSQL .. 干杯!
这是我的代码@JayBhatt,必须更正才能运行以下代码:
<?php
$myServer = "localhost";
$myUser = "sa";
$myPass = "joseph04";
$myDB = "cars";
//connection to the database
$dbhandle = mssql_connect($myServer, $myUser, $myPass)
or die("Couldn't connect to SQL Server on $myServer");
//select a database to work with
$selected = mssql_select_db($myDB, $dbhandle)
or die("Couldn't open database $myDB");
//declare the SQL statement that will query the database
$query = "SELECT brand, model, year ";
$query .= "FROM cars ";
$query .= "WHERE brand='Honda'";
//execute the SQL query and return records
$result = mssql_query($query);
$numRows = mssql_num_rows($result);
echo "<h1>" . $numRows . " Row" . ($numRows == 1 ? "" : "s") . " Returned </h1>";
//display the results
while($row = mssql_fetch_array($result))
{
echo "<li>" . $row["brand"] . $row["model"] . $row["year"] . "</li>";
}
//close the connection
mssql_close($dbhandle);
?>
【问题讨论】:
-
另一方面,通过 SA 用户帐户连接到数据库并不明智,因为它可以完全控制每个数据库架构和 mssql 服务器设置。最佳做法是让子用户对单个或几个模式具有足够的权限,具体取决于规模
标签: php sql-server wamp sqlsrv