phpinfo显示已经成功了啊
报错:Error:SQLSTATE[IMSSP]: An invalid keyword 'host' was specified in the DSN string
求大神解答,已经困扰两天了,很紧急,在线等
测试代码如下:
$username = "sa";
$pwd = "246521";
try
{
$dbh = new PDO('sqlsrv:host=localhost;dbname=test',$username,$pwd); $sqlstri = "select * from test1"; foreach ($dbh->query($sqlstri) as $row) {
print_r($row); }
}
catch (PDOException $e)
{
print "Error:".$e->getMessage()."<br>";
}
报错:Error:SQLSTATE[IMSSP]: An invalid keyword 'host' was specified in the DSN string
求大神解答,已经困扰两天了,很紧急,在线等
测试代码如下:
$username = "sa";
$pwd = "246521";
try
{
$dbh = new PDO('sqlsrv:host=localhost;dbname=test',$username,$pwd); $sqlstri = "select * from test1"; foreach ($dbh->query($sqlstri) as $row) {
print_r($row); }
}
catch (PDOException $e)
{
print "Error:".$e->getMessage()."<br>";
}
解决方案 »
- 关于数据库设计。一篇文章添加多张图片
- mysql导入60M文件报错,请各位大虾帮我解决下
- google checkout支付问题(php)
- centos 6.0 安装PHP make: *** 没有指明目标并且找不到 makefile。 停止。
- wordpress页面如何传参给asp.net页面
- discuz 怎么传参数的? 【求惑】
- Warning: require_once
- 调试php代码 是用zend studio 的 debugger插件吗? 求个下载地址 官网上的链接我无法下载 谢谢
- nginx支持thinkphp的pathinfo
- wamp在线考试系统搭建
- wordpress隐藏了一类文章如何让分页不计入
- PHP源码zend加密求解密
http://www.php.net/manual/zh/ref.pdo-sqlsrv.connection.phpExample #1 PDO_SQLSRV DSN examplesThe following example shows how to connecto to a specified MS SQL Server database:$c = new PDO("sqlsrv:Server=localhost;Database=testdb", "UserName", "Password");
The following example shows how to connect to a MS SQL Server database on a specified port:$c = new PDO("sqlsrv:Server=localhost,1521;Database=testdb", "UserName", "Password");
The following example shows how to connecto to a SQL Azure database with server ID 12345abcde. Note that when you connect to SQL Azure with PDO, your username will be UserName@12345abcde (UserName@ServerId).$c = new PDO("sqlsrv:Server=12345abcde.database.windows.net;Database=testdb", "UserName@12345abcde", "Password");