【发布时间】:2017-05-15 11:57:00
【问题描述】:
我在 Windows7 上使用 Apache 2.4.23、PHP 5.6.29 和 MYSQL Server 5.5 手动设置了 wamp 服务器。每次我尝试连接到 MySQL 时都会收到错误消息:
致命错误:调用未定义函数 mysql_connect
我尝试了以下 stackoverflow 解决方案,但在 c:\PHP 中找不到任何 libmysql.dll,也无法将 php_mysql.dll 从 c:\PHP 复制到C:\Windows\System32 卓有成效: Call to undefined function mysql_connect
我的phpinfo() 的输出:
https://jsfiddle.net/ad0gd90y/
我还查看了 Apache 中的错误日志文件:
Installing Apache HTTP Server 2.x with
DomainName = example.com
ServerName = www.example.com
ServerAdmin = admin@example.com
ServerPort = 80
ServerSslPort = 443
ServerRoot = c:/Apache24
Rewrote docs/conf/extra/httpd-autoindex.conf.in
to c:/Apache24/conf/original/extra/httpd-autoindex.conf
Rewrote docs/conf/extra/httpd-default.conf.in
to c:/Apache24/conf/original/extra/httpd-default.conf
Rewrote docs/conf/extra/httpd-ssl.conf.in
to c:/Apache24/conf/original/extra/httpd-ssl.conf
Rewrote docs/conf/extra/httpd-multilang-errordoc.conf.in
to c:/Apache24/conf/original/extra/httpd-multilang-errordoc.conf
Rewrote docs/conf/extra/httpd-info.conf.in
to c:/Apache24/conf/original/extra/httpd-info.conf
Rewrote docs/conf/extra/httpd-userdir.conf.in
to c:/Apache24/conf/original/extra/httpd-userdir.conf
Rewrote docs/conf/extra/httpd-mpm.conf.in
to c:/Apache24/conf/original/extra/httpd-mpm.conf
Rewrote docs/conf/httpd.conf.in
to c:/Apache24/conf/original/httpd.conf
Rewrote docs/conf/extra/proxy-html.conf.in
to c:/Apache24/conf/original/extra/proxy-html.conf
Rewrote docs/conf/extra/httpd-vhosts.conf.in
to c:/Apache24/conf/original/extra/httpd-vhosts.conf
Rewrote docs/conf/extra/httpd-dav.conf.in
to c:/Apache24/conf/original/extra/httpd-dav.conf
Rewrote docs/conf/extra/httpd-languages.conf.in
to c:/Apache24/conf/original/extra/httpd-languages.conf
Rewrote docs/conf/extra/httpd-manual.conf.in
to c:/Apache24/conf/original/extra/httpd-manual.conf
Duplicated c:/Apache24/conf/original/extra/httpd-autoindex.conf
to c:/Apache24/conf/extra/httpd-autoindex.conf
Duplicated c:/Apache24/conf/original/extra/httpd-default.conf
to c:/Apache24/conf/extra/httpd-default.conf
Duplicated c:/Apache24/conf/original/extra/httpd-ssl.conf
to c:/Apache24/conf/extra/httpd-ssl.conf
Duplicated c:/Apache24/conf/original/extra/httpd-multilang-errordoc.conf
to c:/Apache24/conf/extra/httpd-multilang-errordoc.conf
Duplicated c:/Apache24/conf/original/extra/httpd-info.conf
to c:/Apache24/conf/extra/httpd-info.conf
Duplicated c:/Apache24/conf/original/extra/httpd-userdir.conf
to c:/Apache24/conf/extra/httpd-userdir.conf
Duplicated c:/Apache24/conf/original/extra/httpd-mpm.conf
to c:/Apache24/conf/extra/httpd-mpm.conf
Duplicated c:/Apache24/conf/original/httpd.conf
to c:/Apache24/conf/httpd.conf
Duplicated c:/Apache24/conf/original/magic
to c:/Apache24/conf/magic
Duplicated c:/Apache24/conf/original/charset.conv
to c:/Apache24/conf/charset.conv
Duplicated c:/Apache24/conf/original/extra/proxy-html.conf
to c:/Apache24/conf/extra/proxy-html.conf
Duplicated c:/Apache24/conf/original/extra/httpd-vhosts.conf
to c:/Apache24/conf/extra/httpd-vhosts.conf
Duplicated c:/Apache24/conf/original/extra/httpd-dav.conf
to c:/Apache24/conf/extra/httpd-dav.conf
Duplicated c:/Apache24/conf/original/mime.types
to c:/Apache24/conf/mime.types
Duplicated c:/Apache24/conf/original/extra/httpd-languages.conf
to c:/Apache24/conf/extra/httpd-languages.conf
Duplicated c:/Apache24/conf/original/extra/httpd-manual.conf
to c:/Apache24/conf/extra/httpd-manual.conf
我对如何解决这个问题完全无能为力。还有什么是 libmysql.dll 用于?有没有安装顺序可以搞定(我最后安装了apache,然后是php和mysql)?提前致谢!
【问题讨论】:
-
您是否尝试过使用
mysqli_进行连接/查询?您没有发布任何 php/mysql 代码,所以很难说。 -
我会尽快尝试 mysqli_ 版本的代码。我尝试使用 mysql_connect("$host", "$username", "$password") 后跟 mysql_select_db("$db_name") 的简单连接脚本,这在我用 PHP 部署 wamp 服务器的旧 XP 机器上运行良好5.2.5
-
这也可能是权限问题。您是否尝试以管理员身份运行?如果你还没有。 Win7 可以这样敏感。您说您进行了手动安装;您应该尝试卸载并选择自动安装,如果使用 32,请选择正确的安装,如果您有 64 位系统,请使用 64 位。
-
Deprecated 表示不再支持或推荐它,并且会发出警告(但仍应运行)。你是对的,它应该在 PHP 5.6.29 中仍然可以工作。