WordPress database error Table
-
I have updated to the latest version, i want to clean old analysis data, i uses tools option but i get this error
WordPress database error Table ‘wp_seopress_content_analysis’ doesn’t exist for query DELETE FROM
wp_seopress_content_analysis
made by do_action(‘admin_init’), WP_Hook->do_action, WP_Hook->apply_filters, seopress_clean_content_scansThanks
-
Hi,
try to edit this file:
wp-seopress/inc/functions/options-import-export.php
Line 64, replace the code by this one:
// Delete all content scans function seopress_clean_content_scans() { if (empty($_POST['seopress_action']) || 'clean_content_scans' != $_POST['seopress_action']) { return; } if (!wp_verify_nonce($_POST['seopress_clean_content_scans_nonce'], 'seopress_clean_content_scans_nonce')) { return; } if (!current_user_can(seopress_capability('manage_options', 'cleaning'))) { return; } // Delete cache option delete_option('seopress_content_analysis_api_in_progress'); global $wpdb; // Clean our post metas $sql = 'DELETE FROM
' . $wpdb->prefix . 'postmeta
WHEREmeta_key
IN ( \'_seopress_analysis_data\', \'_seopress_content_analysis_api\', \'_seopress_analysis_data_oxygen\', \'_seopress_content_analysis_api_in_progress\')'; $sql = $wpdb->prepare($sql); $wpdb->query($sql); // Clean custom table if it exists if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}seopress_content_analysis'") === $wpdb->prefix . 'seopress_content_analysis') { $sql = 'DELETE FROM' . $wpdb->prefix . 'seopress_content_analysis
'; $sql = $wpdb->prepare($sql); $wpdb->query($sql); } wp_safe_redirect(admin_url('admin.php?page=seopress-import-export')); exit; } add_action('admin_init', 'seopress_clean_content_scans');Is it better?
Please let us know, thanks!
I get a error after editing
fatal error: uncaught error: syntax error, unexpected token “return”on line 70
Thanks
Can you paste / host on a Drive the complete edited file please?
Thanks
<?php
defined(‘ABSPATH’) or exit(‘Please don’t call the plugin directly. Thanks :)’);
///////////////////////////////////////////////////////////////////////////////////////////////////
//Import / Exports settings page
///////////////////////////////////////////////////////////////////////////////////////////////////
//Export SEOPress Settings to JSON
function seopress_export_settings() {
if (empty($_POST[‘seopress_action’]) || ‘export_settings’ != $_POST[‘seopress_action’]) {
return;
}
if ( ! wp_verify_nonce($_POST[‘seopress_export_nonce’], ‘seopress_export_nonce’)) {
return;
}
if ( ! current_user_can(seopress_capability(‘manage_options’, ‘export_settings’))) {
return;
}$settings = seopress_get_service('ExportSettings')->handle(); ignore_user_abort(true); nocache_headers(); header('Content-Type: application/json; charset=utf-8'); header('Content-Disposition: attachment; filename=seopress-settings-export-' . date('m-d-Y') . '.json'); header('Expires: 0'); echo json_encode($settings); exit;
}
add_action(‘admin_init’, ‘seopress_export_settings’);//Import SEOPress Settings from JSON
function seopress_import_settings() {
if (empty($_POST[‘seopress_action’]) || ‘import_settings’ != $_POST[‘seopress_action’]) {
return;
}
if ( ! wp_verify_nonce($_POST[‘seopress_import_nonce’], ‘seopress_import_nonce’)) {
return;
}
if ( ! current_user_can(seopress_capability(‘manage_options’, ‘import_settings’))) {
return;
}$extension = pathinfo($_FILES['import_file']['name'], PATHINFO_EXTENSION); if ('json' != $extension) { wp_die(__('Please upload a valid .json file', 'wp-seopress')); } $import_file = $_FILES['import_file']['tmp_name']; if (empty($import_file)) { wp_die(__('Please upload a file to import', 'wp-seopress')); } $settings = (array) json_decode(seopress_remove_utf8_bom(file_get_contents($import_file)), true); seopress_get_service('ImportSettings')->handle($settings); wp_safe_redirect(admin_url('admin.php?page=seopress-import-export&success=true')); exit;
}
add_action(‘admin_init’, ‘seopress_import_settings’);//Delete all content scans
function seopress_clean_content_scans() {
if (empty($_POST[‘seopress_action’]) || ‘clean_content_scans’ != $_POST[‘seopress_action’]) {
return;
}
if ( ! wp_verify_nonce($_POST[‘seopress_clean_content_scans_nonce’], ‘seopress_clean_content_scans_nonce’)) {
return;
}
if ( ! current_user_can(seopress_capability(‘manage_options’, ‘cleaning’))) {
return;
}// Delete cache option delete_option('seopress_content_analysis_api_in_progress'); global $wpdb; // Clean our post metas $sql = 'DELETE FROM
' . $wpdb->prefix . 'postmeta
WHEREmeta_key
IN ( \'_seopress_analysis_data\', \'_seopress_content_analysis_api\', \'_seopress_analysis_data_oxygen\', \'_seopress_content_analysis_api_in_progress\')'; $sql = $wpdb->prepare($sql); $wpdb->query($sql); // Clean custom table $sql = 'DELETE FROM' . $wpdb->prefix . 'seopress_content_analysis
'; $sql = $wpdb->prepare($sql); $wpdb->query($sql); wp_safe_redirect(admin_url('admin.php?page=seopress-import-export')); exit;}
add_action(‘admin_init’, ‘seopress_clean_content_scans’);//Reset SEOPress Notices Settings
function seopress_reset_notices_settings() {
if (empty($_POST[‘seopress_action’]) || ‘reset_notices_settings’ != $_POST[‘seopress_action’]) {
return;
}
if ( ! wp_verify_nonce($_POST[‘seopress_reset_notices_nonce’], ‘seopress_reset_notices_nonce’)) {
return;
}
if ( ! current_user_can(seopress_capability(‘manage_options’, ‘reset_settings’))) {
return;
}global $wpdb; $wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE 'seopress_notices' "); wp_safe_redirect(admin_url('admin.php?page=seopress-import-export')); exit;
}
add_action(‘admin_init’, ‘seopress_reset_notices_settings’);//Reset SEOPress Settings
function seopress_reset_settings() {
if (empty($_POST[‘seopress_action’]) || ‘reset_settings’ != $_POST[‘seopress_action’]) {
return;
}
if ( ! wp_verify_nonce($_POST[‘seopress_reset_nonce’], ‘seopress_reset_nonce’)) {
return;
}
if ( ! current_user_can(seopress_capability(‘manage_options’, ‘reset_settings’))) {
return;
}global $wpdb; $wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE 'seopress_%' "); wp_safe_redirect(admin_url('admin.php?page=seopress-import-export')); exit;
}
add_action(‘admin_init’, ‘seopress_reset_settings’);<?php defined('ABSPATH') or exit('Please don’t call the plugin directly. Thanks :)'); /////////////////////////////////////////////////////////////////////////////////////////////////// //Import / Exports settings page /////////////////////////////////////////////////////////////////////////////////////////////////// //Export SEOPress Settings to JSON function seopress_export_settings() { if (empty($_POST['seopress_action']) || 'export_settings' != $_POST['seopress_action']) { return; } if ( ! wp_verify_nonce($_POST['seopress_export_nonce'], 'seopress_export_nonce')) { return; } if ( ! current_user_can(seopress_capability('manage_options', 'export_settings'))) { return; } $settings = seopress_get_service('ExportSettings')->handle(); ignore_user_abort(true); nocache_headers(); header('Content-Type: application/json; charset=utf-8'); header('Content-Disposition: attachment; filename=seopress-settings-export-' . date('m-d-Y') . '.json'); header('Expires: 0'); echo json_encode($settings); exit; } add_action('admin_init', 'seopress_export_settings'); //Import SEOPress Settings from JSON function seopress_import_settings() { if (empty($_POST['seopress_action']) || 'import_settings' != $_POST['seopress_action']) { return; } if ( ! wp_verify_nonce($_POST['seopress_import_nonce'], 'seopress_import_nonce')) { return; } if ( ! current_user_can(seopress_capability('manage_options', 'import_settings'))) { return; } $extension = pathinfo($_FILES['import_file']['name'], PATHINFO_EXTENSION); if ('json' != $extension) { wp_die(__('Please upload a valid .json file', 'wp-seopress')); } $import_file = $_FILES['import_file']['tmp_name']; if (empty($import_file)) { wp_die(__('Please upload a file to import', 'wp-seopress')); } $settings = (array) json_decode(seopress_remove_utf8_bom(file_get_contents($import_file)), true); seopress_get_service('ImportSettings')->handle($settings); wp_safe_redirect(admin_url('admin.php?page=seopress-import-export&success=true')); exit; } add_action('admin_init', 'seopress_import_settings'); // Delete all content scans function seopress_clean_content_scans() { if (empty($_POST['seopress_action']) || 'clean_content_scans' != $_POST['seopress_action']) { return; } if (!wp_verify_nonce($_POST['seopress_clean_content_scans_nonce'], 'seopress_clean_content_scans_nonce')) { return; } if (!current_user_can(seopress_capability('manage_options', 'cleaning'))) { return; } // Delete cache option delete_option('seopress_content_analysis_api_in_progress'); global $wpdb; // Clean our post metas $sql = 'DELETE FROM
' . $wpdb->prefix . 'postmeta
WHEREmeta_key
IN ( \'_seopress_analysis_data\', \'_seopress_content_analysis_api\', \'_seopress_analysis_data_oxygen\', \'_seopress_content_analysis_api_in_progress\')'; $sql = $wpdb->prepare($sql); $wpdb->query($sql); // Clean custom table if it exists if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}seopress_content_analysis'") === $wpdb->prefix . 'seopress_content_analysis') { $sql = 'DELETE FROM' . $wpdb->prefix . 'seopress_content_analysis
'; $sql = $wpdb->prepare($sql); $wpdb->query($sql); } wp_safe_redirect(admin_url('admin.php?page=seopress-import-export')); exit; } add_action('admin_init', 'seopress_clean_content_scans'); //Reset SEOPress Notices Settings function seopress_reset_notices_settings() { if (empty($_POST['seopress_action']) || 'reset_notices_settings' != $_POST['seopress_action']) { return; } if ( ! wp_verify_nonce($_POST['seopress_reset_notices_nonce'], 'seopress_reset_notices_nonce')) { return; } if ( ! current_user_can(seopress_capability('manage_options', 'reset_settings'))) { return; } global $wpdb; $wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE 'seopress_notices' "); wp_safe_redirect(admin_url('admin.php?page=seopress-import-export')); exit; } add_action('admin_init', 'seopress_reset_notices_settings'); //Reset SEOPress Settings function seopress_reset_settings() { if (empty($_POST['seopress_action']) || 'reset_settings' != $_POST['seopress_action']) { return; } if ( ! wp_verify_nonce($_POST['seopress_reset_nonce'], 'seopress_reset_nonce')) { return; } if ( ! current_user_can(seopress_capability('manage_options', 'reset_settings'))) { return; } global $wpdb; $wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE 'seopress_%' "); wp_safe_redirect(admin_url('admin.php?page=seopress-import-export')); exit; } add_action('admin_init', 'seopress_reset_settings');Try to copy / paste the all file (wp-seopress/inc/functions/options-import-export.php).
You should not encounter any error.
May I know your PHP version? WP version? SEOPress?
Thx
Thanks, the error has gone.
Php version: 8.0.30
wp version: 6.4.3
seopress: 7.4But still after cleaning analysis data, the refresh analysis button in product edit is not working, i see only duplicate analysis data when i update with save draft button,
Thanks
Hi,
thank you for this update.
Can you take a screenshot / video of the issue please?
I’m not sure to understand what you mean.
Thx
Due to inactivity, we’re now closing this topic.
Thank you for your understanding.
- The topic ‘WordPress database error Table’ is closed to new replies.