调用未定义的函数mysql

调用未定义的函数mysql

本文介绍了调用未定义的函数mysql_connect的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚在家用PC上安装了PHP和Apache.当我尝试调用函数mysql_connect时,我得到:

I just installed PHP and Apache on my home PC. When I try to call function mysql_connect I get:

fatal error: call to undefined function mysql_connect.

我已经加载了php.ini,其中没有注释的行extension=php_mysql.dllextension=php_mysqli.dll,并将扩展目录更改为extension_dir = "C:\php\ext"-这是文件php_mysql.dll和php_mysqli.dll所在的目录.我该如何解决这个问题?

I have loaded php.ini where I have uncommented lines extension=php_mysql.dll andextension=php_mysqli.dll and changed extension directory to extension_dir = "C:\php\ext" - which is the directory where files php_mysql.dll and php_mysqli.dll are. How can I fix this problem?

phpinfo()的输出: http://jsfiddle.net/MMTwA/

推荐答案

查看您的phpinfo()输出后,似乎未加载mysql扩展.我怀疑您可能在编辑错误的php.ini文件(可能有多个副本).确保您正在编辑 C:\ php \ php.ini 上的php文件(还要检查以确保C:\ Windows中没有第二个副本).

After looking at your phpinfo() output, it appears the mysql extensions are not being loaded. I suspect you might be editing the wrong php.ini file (there might be multiple copies). Make sure you are editing the php file at C:\php\php.ini (also check to make sure there is no second copy in C:\Windows).

此外,您还应检查Apache日志中是否有错误(应位于Apache安装目录的\ logs \目录中.

Also, you should check your Apache logs for errors (should be in the \logs\ directory in your Apache install.

如果您还没有阅读下面的内容,那么我将看一下评论部分,因为似乎很多人都对此设置感到奇怪.一些评论者提供了他们用来使其正常工作的解决方案.

If you haven't read the below, I would take a look at the comments section, because it seems like a lot of people experience quirks with setting this up. A few commenters offer solutions they used to get it working.

http://php.net/manual/en/install.windows.extensions.php

另一个常见的解决方案似乎是将libmysql.dll和php_mysql.dll从c:\ PHP复制到C:\ Windows \ System32.

Another common solution seems to be to copy libmysql.dll and php_mysql.dll from c:\PHP to C:\Windows\System32.

这篇关于调用未定义的函数mysql_connect的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 00:57