关于 php 配置问题

小土bibox 2012-02-23 07:00:12
环境: win7 iis7.5 php5.3.10 mssql 2008


要用php 连接sql下的微软的sqlsrv。 装好可以hello world


使用测试微软的测试用例:

<?php
/*Connect to the local server using Windows Authentication and
specify the AdventureWorks database as the database in use. */
$serverName = "'local'";
$conn = sqlsrv_connect( $serverName);

if( $conn === false )
{
echo "Could not connect.\n";
die( print_r( sqlsrv_errors(), true));
}

if( $client_info = sqlsrv_client_info( $conn))
{
foreach( $client_info as $key => $value)
{
echo $key.": ".$value."\n";
}
}
else
{
echo "Client info error.\n";
}

/* Close connection resources. */
sqlsrv_close( $conn);
?>


结果出现这个:

Could not connect. Array ( [0] => Array ( [0] => 08001 [SQLSTATE] => 08001 [1] => 53 [code] => 53 [2] => [Microsoft][SQL Server Native Client 10.0]Named Pipes Provider: Could not open a connection to SQL Server [53]. [message] => [Microsoft][SQL Server Native Client 10.0]Named Pipes Provider: Could not open a connection to SQL Server [53]. ) [1] => Array ( [0] => HYT00 [SQLSTATE] => HYT00 [1] => 0 [code] => 0 [2] => [Microsoft][SQL Server Native Client 10.0]Login timeout expired [message] => [Microsoft][SQL Server Native Client 10.0]Login timeout expired ) [2] => Array ( [0] => 08001 [SQLSTATE] => 08001 [1] => 53 [code] => 53 [2] => [Microsoft][SQL Server Native Client 10.0]A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online. [message] => [Microsoft][SQL Server Native Client 10.0]A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online. ) )

这他娘是怎么一会事。我搞了两天了。要疯掉了。 谁能救命
...全文
140 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
chchmlml 2012-02-24
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 black2bi 的回复:]

问题已解决呵呵。 虽然是自己找的。呵呵。

在多问一下。大家开发php是用什么工具。

我刚弄php从.net 那边过来的。我现在用notepad++ 这个东西开发好简陋啊。是跟vs比。

呵呵呵用惯了集成环境。大家有没有好的集成编程软件推荐一下。
[/Quote]
zend studio 、eclipsephp、netbeans
changjiangzhibin 2012-02-24
  • 打赏
  • 举报
回复
Zend,EditPlus
小土bibox 2012-02-24
  • 打赏
  • 举报
回复
问题已解决呵呵。 虽然是自己找的。呵呵。

在多问一下。大家开发php是用什么工具。

我刚弄php从.net 那边过来的。我现在用notepad++ 这个东西开发好简陋啊。是跟vs比。

呵呵呵用惯了集成环境。大家有没有好的集成编程软件推荐一下。
ssd189 2012-02-23
  • 打赏
  • 举报
回复
phpstudy
zhgwbzhd 2012-02-23
  • 打赏
  • 举报
回复
哦,你的是5.3.
需要从微软下载新的驱动。
使用方法也不太不样。
不过大概差不多。
zhgwbzhd 2012-02-23
  • 打赏
  • 举报
回复
请参见我的帖子。
代码是没问题的。
http://topic.csdn.net/u/20120222/13/fbeeca0a-838c-4721-84ba-bbe4cf20203f.html
xuzuning 2012-02-23
  • 打赏
  • 举报
回复
$serverName = "'local'";
$conn = sqlsrv_connect( $serverName);
????

连接数据库连用户名都不要吗?什么时候这样大方了?
local 表示当前服务i中唯一的实例,家那么多引号干什么

20,359

社区成员

发帖
与我相关
我的任务
社区描述
“超文本预处理器”,是在服务器端执行的脚本语言,尤其适用于Web开发并可嵌入HTML中。PHP语法利用了C、Java和Perl,该语言的主要目标是允许web开发人员快速编写动态网页。
phpphpstorm 技术论坛(原bbs)
社区管理员
  • 开源资源社区
  • phpstory
  • xuzuning
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧