Forum Replies Created

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter astroo

    (@astroo)

    Thanks you @wpmajestic. It works

    Thread Starter astroo

    (@astroo)

    @fierevere I check PHP memory limit. It is okay. No issue in that.

    Can you check on this page:

    • This reply was modified 2 months, 1 week ago by Yui.
    • This reply was modified 2 months, 1 week ago by James Huff. Reason: link moved to proper field in OP

    Hi Daniel,

    The location of your old image data depends on your setup. If you’re using a content management system like WordPress, the images are usually stored in the /wp-content/uploads/ folder on your old domain’s server. You can export them via FTP or your hosting control panel.

    If you’re manually managing your site, check the directory where your images were uploaded. After retrieving the files, you can upload them to your new domain.

    From your description and code, it seems you want to transfer user data from a local WordPress database to a remote database. Your approach is almost correct, but there are a few issues that could be causing the blank page or preventing the code from working. Key Points to Check and Suggestions:

    1. Check for PHP Errors:
      Blank pages often indicate a PHP error. Even though you have enabled debugging, PHP errors might not be outputted correctly. You can add the following code at the top of your file to ensure all errors are displayed:
       ini_set('display_errors', 1);
       ini_set('display_startup_errors', 1);
       error_reporting(E_ALL);
    1. Syntax Error in Your Code:
      There is a mistake in this line:
       $external_users = $other_db->'users';

    It should be:

       $external_users = $other_db->prefix . 'users'; // Assuming 'users' table has a prefix

    or simply:

       $external_users = 'users';

    The -> operator cannot be used to directly access a string. You need to correct that.

    1. Inserting Data into the Remote Database:
      The wpdb::insert() method should be called on the correct $other_db instance, not the local $wpdb instance. Your code should look like this:
       $other_db->insert(
           $external_users,
           array(
               'username' => $user->user_login,
               'hash'     => $user->user_pass,
               'email'    => $user->user_email,
           )
       );
    1. Database Table Structure:
      Ensure that the remote database has the exact table structure for the users table and that the column names match. For example, if the column names are user_login, user_pass, and user_email, use those exact names.
    2. Debugging:
      You can add logging to see if your code runs up to a certain point. For example:
       error_log('Reached this point before inserting data.');

    Check the debug.log file in the wp-content directory for the logged messages.

    1. Database Connection Validation:
      You’re currently checking the connection like this:
       if (!$other_db) {
           echo $wpdb->show_errors();
       }

    However, $other_db is an object, so this check will always pass. Instead, validate the connection using the last_error property:

       if ( $other_db->last_error ) {
           error_log('Database connection error: ' . $other_db->last_error);
       } else {
           echo 'Connected successfully';
       }
    1. Avoid Hardcoding the Table Name:
      WordPress tables usually have prefixes (like wp_). Use the $wpdb->prefix property to handle this dynamically if needed.

    Final Revised Code Example:

    require __DIR__ . '/wp-load.php';
    define( 'WP_DEBUG', true );
    define( 'WP_DEBUG_LOG', true );
    
    ini_set('display_errors', 1);
    ini_set('display_startup_errors', 1);
    error_reporting(E_ALL);
    
    global $wpdb;
    
    $other_db = new wpdb($other_db_user, $other_db_password, $other_db_name, $other_db_host);
    
    if ( $other_db->last_error ) {
        error_log('Database connection error: ' . $other_db->last_error);
    } else {
        echo 'Connected successfully';
    }
    
    $user = get_userdata($user_id);
    
    if ( $user ) {
        $external_users = 'users'; // Adjust the table name as needed
    
        $result = $other_db->insert(
            $external_users,
            array(
                'username' => $user->user_login,
                'hash'     => $user->user_pass,
                'email'    => $user->user_email,
            )
        );
    
        if ( $result === false ) {
            error_log('Insert error: ' . $other_db->last_error);
        } else {
            echo 'Data inserted successfully.';
        }
    } else {
        error_log('User not found.');
    }

    Additional Tips:

    • Make sure the remote database user has the correct permissions to insert data.
    • Ensure that the remote table structure and column names match the data you’re inserting.
    • Check the debug.log file and PHP error output for clues if the issue persists.

    This should resolve your issues and help in successfully inserting data into the remote database.

    Possible Solution for Product Images Duplicating on Mobile Devices

    It sounds like the issue might be related to the WooCommerce hover effect or a theme-related conflict. Here’s a step-by-step approach to troubleshoot and hopefully resolve the issue:

    1. Disable WooCommerce Image Hover Effects:
      • Add the following CSS code to your theme’s Additional CSS section in the Customizer:
      cssCopy code.single-product div.product .woocommerce-product-gallery .flex-control-nav, .single-product div.product .woocommerce-product-gallery__trigger { display: none !important; } .single-product div.product .woocommerce-product-gallery .woocommerce-product-gallery__wrapper { pointer-events: none; } This code disables the hover effect and may prevent the images from duplicating.
    2. Check for Theme or Plugin Conflicts:
      • Temporarily switch to a default WordPress theme like Twenty Twenty-One to see if the issue persists. If the problem disappears, it’s likely a theme conflict.
      • Deactivate all plugins except WooCommerce and see if the problem is resolved. If it is, reactivate each plugin one by one to identify the culprit.
    3. Clear Mobile Cache:
      • Clear the cache on your mobile browser to ensure that you’re not seeing a cached version of your site with the issue.
    4. Test Different Devices/Browsers:
      • Test your site on different mobile devices and browsers to see if the issue is consistent across all platforms.
    5. Responsive Image Settings:
      • Ensure that your theme is correctly handling responsive images. Some themes have settings specifically for mobile images, so double-check those.

    If these steps don’t resolve the issue, it might be helpful to share more details like the theme you’re using or any customizations you’ve applied, as that can help others provide more targeted advice.

Viewing 5 replies - 1 through 5 (of 5 total)