php - WordPress - mysql_query() : Access denied for user 'www-data' @'localhost' (using password: NO) error on production server

标签 php mysql wordpress

当我启用 wordpress Debug模式时,我收到一条警告消息。

Warning: mysql_query(): Access denied for user 'www-data'@'localhost' (using password: NO) in /var/www/html/blog/wp-content/plugins/test/manage_registrations.php on line 46

Warning: mysql_query(): A link to the server could not be established in /var/www/html/blog/wp-content/plugins/test/manage_registrations.php on line 46

PHP代码:

$extrawhere1=" order by id desc LIMIT $start, $limit";
$sqlSearch="select * from visa where 1=1 $extrawhere $extrawhere1";
$query="select * from visa where 1=1 $extrawhere order by id desc ";
$_SESSION['export_data']=$query;

$num=@mysql_num_rows(mysql_query($query));
$select_product=mysql_query($sqlSearch);

我试过用

$select_product=$wpdb->query($sqlSearch);

但我仍然收到错误消息。此错误仅出现在生产服务器上,而不出现在本地服务器上。

最佳答案

将这两行写在文件的顶部以检查是否有任何错误

ini_set('error_reporting', E_ALL);
ini_set('display_errors', 1);

还要检查你的 config.php 数据库连接(正确与否)

可能是您的数据库负载增加到连接无法继续进行的程度。

关于php - WordPress - mysql_query() : Access denied for user 'www-data' @'localhost' (using password: NO) error on production server,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33991199/

相关文章:

php - 我不断收到此错误 file_get_contents(无法打开流 : HTTP request failed! HTTP/1.1 400 BAD REQUEST

mysql - C 中的命名空间冲突

php - 尝试在保存帖子之前获取 ACF 字段的默认值

php - 使用具有嵌套插件依赖项的自定义 wordpress 插件进行单元测试

javascript - 单击按钮时更新数据库

PHP Array 删除重复的键值并只显示一个

python - Mac OS X Mavericks 无法安装 MySQL-python==1.2.4

php - Magento 迁移中断 - 子页面返回 404

wordpress - 如何为 WordPress 中的所有出站链接设置 nofollow rel 属性?有插件吗?

php - curl_exec() 总是返回 false