mysql_connect()失败并显示空警告 [英] mysql_connect() fails with empty warning

查看:144
本文介绍了mysql_connect()失败并显示空警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用IIS在Windows Server 2003计算机上设置PHP/MYSQL.我已经安装了PHP 5.3.8和MySQL 5.5. PHP已配置为使用FastCGI.

I'm in the process of setting up PHP / MYSQL on a Windows Server 2003 machine, with IIS. I have installed PHP 5.3.8 and MySQL 5.5. PHP is configured to use FastCGI.

php.ini中,我没有注释以下行:

In php.ini I have the following lines uncommented:

extension=php_mysql.dll

extension=php_mysqli.dll

这是我的代码:

<?php
$con = mysql_connect("127.0.0.1","root","test");
if (!$con)
  {
  die('Could not connect: $php_errormsg' . mysql_errno() . ": " . mysql_error(). "\n");
  }
echo "connected"; 
?>

以下是输出:

PHP Warning: mysql_connect(): in C:\Inetpub\wwwroot\mysqltest.php on line 2

我可以从在另一台Web服务器上运行的PHP页面连接到该服务器上的MYSQL数据库-因此,我知道我的MYSQL数据库正确地接受了连接.

I can connect to the MYSQL database on this server from a PHP page running on another webserver - so I know that my MYSQL database is correctly accepting connections.

在此方面的任何帮助将不胜感激

Any help on this would be greatly appreciated

推荐答案

显然我遇到了权限问题.我可以按照以下步骤解决它:

Apparently I had a permissions issue. I was able to resolve it by following these steps:

从Windows资源管理器中,我...

From Windows Explorer, I...

  • 右键单击C:\ Inetpub
  • 进入属性">安全性">权限"
  • 选择替换所有子对象上的权限条目,并在此处显示适用于子对象的条目"
  • 点击应用"
  • 通过在命令提示符下运行iisreset
  • 重新启动IIS.
  • right-clicked on C:\Inetpub
  • went to Properties > Security > Permissions
  • selected "Replace permission entries on all child objects with entries shown here that apply to child objects"
  • clicked Apply
  • restarted IIS by running iisreset from a command prompt.

这篇关于mysql_connect()失败并显示空警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆