在php.ini中启用了mysql,但是我仍然收到对未定义函数mysql_connect()的调用 [英] mysql is enabled in php.ini but I'm still getting Call to undefined function mysql_connect()

查看:128
本文介绍了在php.ini中启用了mysql,但是我仍然收到对未定义函数mysql_connect()的调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一台Windows 2008服务器,今天早上我们到办公室时,发现mysql无法正常工作

We have a Windows 2008 server, this morning when we came to the office, we saw that mysql is not working

对于一个简单的连接功能,我们会收到此错误

We are getting this error for a simple connect function

Fatal error: Call to undefined function mysql_connect() 

但是奇怪的是,在php.ini文件中启用了mysql扩展.

but the strange thing is that mysql extensions are enabled in php.ini file.

extension=php_mysql.dll

extension=php_mysqli.dll

extension=php_pdo_mysql.dll

根据phpinfo(),使用C:\PHP中的ini文件的php和DLL文件存在于ext文件夹中.

According to phpinfo() , php using the ini file in C:\PHP and the DLL files exist in the ext folder.

我找不到解决方法,或者至少无法找出导致这种情况的原因.

I cannot find a way to solve or at least to find out what is causing this.

如果有人能给我一些建议,我将不胜感激

I would be grateful if someone could give me some advice

预先感谢

推荐答案

出于调试目的,请尝试

if ( !function_exists('mysql_connect') ) {
    echo '<pre>mysql extension loaded: ', extension_loaded('mysql') ? 'yes':'no', "\r\n";
    $cf = get_cfg_var('cfg_file_path');
    echo 'ini file: ', $cf, "\r\n";
    if ( !$cf || !file_exists($cf) ) {
        echo "no config file\r\n";
    }
    else {
        echo "mysql config options:\r\n";
        $mc = array_filter( file($cf), function($e) { return false!==stripos($e, 'mysql') && false!==stripos($e, 'extension'); });
        echo join("", $mc);
    }
    die('no function mysql_connect</pre>');
}

输出应该类似于

<pre>mysql extension loaded: no
ini file: C:\Develop\php\php.ini
mysql config options:
;extension=php_mysql.dll
;extension=php_mysqli.dll
extension=php_pdo_mysql.dll
no function mysql_connect</pre>

表示extension=php_mysql.dll行已被注释掉(在我的php.ini中).

which indicates that the line extension=php_mysql.dll has been commented out (in my php.ini).

如果此脚本显示php_mysql.dll确实应该已加载,请尝试增加php和您的Web服务器的日志级别并检查日志文件.也许Windows无法加载该dll,因为它依赖于不再存在的另一个dll(在正确的版本中).例如. 我的" ext目录中的php_mysql.dll取决于存在的MSVCR110.DLL,因为我已经安装了Visual Studio,否则将需要安装Visual Studio 2012可再发行组件. Dependency Walker 之类的工具可以向您显示运行应用程序和/或dll所需的dll.

In case this script shows that the php_mysql.dll indeed should have been loaded try to increase the log level of both php and your webserver and check the log file. Maybe windows couldn't load the dll because it depends on another dll which isn't present (in the correct version) anymore. E.g. the php_mysql.dll in "my" ext directory depends on MSVCR110.DLL which is present because I have Visual Studio installed, otherwise installing the Visual Studio 2012 redistributables would be required. Tools like Dependency Walker can show you which dlls are required to run an application and/or dll.

也可能是php_mysql.dll实现了与您的php内核不同的API版本.例如.如果您已安装PHP 5.4,但php_mysql.dll用于php 5.1,则会在日志文件中看到API魔术密钥错误.

Or it could be that the php_mysql.dll implements a different API version than your php core. E.g. if you have PHP 5.4 installed but the php_mysql.dll is for php 5.1 you will see an API magic key error in the log file.

这篇关于在php.ini中启用了mysql,但是我仍然收到对未定义函数mysql_connect()的调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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