Mysql 升级到3.9后Wordpress插件出错
在我将Wordpress安装更新到3.9之后,我不断收到以下错误:Mysql 升级到3.9后Wordpress插件出错,mysql,wordpress,plugins,upgrade,wordpress-3.9,Mysql,Wordpress,Plugins,Upgrade,Wordpress 3.9,在我将Wordpress安装更新到3.9之后,我不断收到以下错误: Warning: mysql_query(): Access denied for user 'www-data'@'localhost' (using password: NO) in /home/sites/wordpress/site/wp-content/plugins/crm/main.php on line 20 Warning: mysql_query(): A link to the server could
Warning: mysql_query(): Access denied for user 'www-data'@'localhost' (using password: NO) in /home/sites/wordpress/site/wp-content/plugins/crm/main.php on line 20
Warning: mysql_query(): A link to the server could not be established in /home/sites/wordpress/site/wp-content/plugins/crm/main.php on line 20
Warning: mysql_fetch_row() expects parameter 1 to be resource, boolean given in /home/sites/wordpress/site/wp-content/plugins/crm/main.php on line 21
我不太明白怎么了。以下是3.9之前的代码:
<?php
session_start();
/**
* Plugin Name: CRM
* Description:
* Version:
* Author:
*
*/
add_action( 'admin_menu', 'menu' );
function menu() {
add_menu_page( 'CRM', 'CRM', 3,'form', 'form' );
}
function form() {
global $wpdb,$current_user,$user_ID;
echo "<h3>CRM</h3>";
$count = mysql_query("SELECT COUNT(id) FROM user_form_data");
$nume2 = mysql_fetch_row($count);
$nume = $nume2[0];
试试这个,希望对你有所帮助
试试这个,希望对你有所帮助
看起来更新更改了mysql用户名和密码。所以问题不在于代码
如果这些设置已更改且不正确,请检查wp-config.php文件。看起来更新更改了mysql用户名和密码。所以问题不在于代码
如果这些设置已更改且不正确,请检查wp-config.php文件。您应该阅读这篇文章
在WordPress3.9中,我们向WPDB添加了一个额外的层,使其在使用PHP5.5或更高版本时切换到使用MySQLIPHP库
对于插件开发人员来说,这意味着您绝对不应该再使用PHP的mysql_*()函数——您可以使用等效的WPDB函数
Try this hope this help
<?php
/**
* Plugin Name: CRM
* Description: any desc
* Author: ABS
*
*/
add_action( 'admin_menu', 'user_data_menu' );
function user_data_menu() {
add_menu_page( 'CRM', 'CRM', 3,'user_data_form', 'user_data_form' );
}
function user_data_form() {
@session_start();
global $wpdb,$current_user,$user_ID;
echo "<h3>CRM</h3>";
$count = mysql_query("SELECT COUNT(id) FROM user_form_data");
$nume2 = mysql_fetch_row($count);
$nume = $nume2[0];
if ( $limit < $nume && empty($_POST['searching']) && empty($_POST['filter_flag']) && empty($_POST['rowsselect']) ) {
$start = $_GET['start'];
$eu = ($start - 0);
$limit = 20;
$this4 = $eu + $limit;
$back = $eu - $limit;
$next = $eu + $limit;
}
} ?>
你应该读这篇文章
在WordPress3.9中,我们向WPDB添加了一个额外的层,使其在使用PHP5.5或更高版本时切换到使用MySQLIPHP库
对于插件开发人员来说,这意味着您绝对不应该再使用PHP的mysql_*()函数——您可以使用等效的WPDB函数
Try this hope this help
<?php
/**
* Plugin Name: CRM
* Description: any desc
* Author: ABS
*
*/
add_action( 'admin_menu', 'user_data_menu' );
function user_data_menu() {
add_menu_page( 'CRM', 'CRM', 3,'user_data_form', 'user_data_form' );
}
function user_data_form() {
@session_start();
global $wpdb,$current_user,$user_ID;
echo "<h3>CRM</h3>";
$count = mysql_query("SELECT COUNT(id) FROM user_form_data");
$nume2 = mysql_fetch_row($count);
$nume = $nume2[0];
if ( $limit < $nume && empty($_POST['searching']) && empty($_POST['filter_flag']) && empty($_POST['rowsselect']) ) {
$start = $_GET['start'];
$eu = ($start - 0);
$limit = 20;
$this4 = $eu + $limit;
$back = $eu - $limit;
$next = $eu + $limit;
}
} ?>
将此更改为wp_结果
$count = mysql_query("SELECT COUNT(id) FROM user_form_data");
$nume2 = mysql_fetch_row($count);
到
将此更改为wp_结果
$count = mysql_query("SELECT COUNT(id) FROM user_form_data");
$nume2 = mysql_fetch_row($count);
到
你看到那些错误消息了吗?代码没有问题,WordPress无法连接到数据库。检查配置中的凭据。检查配置,并尝试使用凭据输入mysql。当我成功登录时,这里似乎没有什么问题。你看到那些错误消息了吗?代码没有问题,WordPress无法连接到数据库。检查配置中的凭据。检查配置,并尝试使用凭据输入mysql。我成功登录后,这里似乎没有什么问题。谢谢你的建议,但在我尝试之后,错误是一样的。不要使用mysql*函数。它们已被弃用。使用WP核心函数或mysqli或pdo。第二,你的数据不安全。清理数据。谢谢你的建议,但在我尝试之后,错误是一样的。不要使用mysql*函数。它们已被弃用。使用WP核心函数或mysqli或pdo。第二,你的数据不安全。清理数据。wp-config.php文件内没有任何更改,其中的凭据可用于访问mysql。wp-config.php文件内没有任何更改,其中的凭据可用于访问mysql。的确!7小时前我用这个解决方案更新了我的问题:)真的!7小时前我用这个解决方案更新了我的问题:)很好的例子。这就是我所做的-将所有旧的mysql替换为$wpdb->好例子。这就是我所做的-用$wpdb->