• shadynicnack

    (@shadynicnack)


    Have a couple questions. Just to get everyone up to date:

    – I had created a new file wp-custom-config.php
    – Use define define( ‘NEW_HOST’, host name); and other details.
    – And add code for DB connect like below

    $newdb = new wpdb($DB_USER, $DB_PASSWORD, $DB_NAME, $DB_HOST);
    $newdb->show_errors();

    – Included this file in wp-config.php file.

    So the wp-customer-config.php looks like:

    $DB_NAME_EXT = ‘database’;

    /** database username */
    /*define(‘DB_USER_EXT’, ‘username’);*/
    $DB_USER_EXT = ‘username’;

    /** database password */
    /*define(‘DB_PASSWORD_EXT’, ‘password’);*/
    $DB_PASSWORD_EXT = ‘password’;

    /** database hostname */
    /*define(‘DB_HOST_EXT’, ‘host’);*/
    $DB_HOST_EXT = ‘host’;

    global $newdb;
    $newdb = new wpdb($DB_NAME_EXT, $DB_USER_EXT, $DB_PASSWORD_EXT, $DB_HOST_EXT );
    $newdb->show_errors();

    Like I mention before, I have included it or should I say required it in the wp-config.php at the bottom after require_once(ABSPATH . ‘wp-settings.php’) and looks like…

    require_once(ABSPATH . ‘external-config.php’);
    _______________________________________________________

    FIRST QUESTION: – I read that you can use $newdb in any file any where. How would you do that? Can I see examples?

    SECOND QUESTION: I want to use the $newdb for the login page. So instead of using the $wpdb, I want to use $newdb to pick and check username and password. How would I do that? Would I need to make a custom login page or can I go into the code and switched databases around? Whats the best practice?

    Please Help…

    [Moderator Note: No bumping, thank you. And please do not post multiple topics for the same question. Duplicate topics will be deleted on sight.]

  • The topic ‘Adding another Database using $wpdb and using the $newdb for login page?’ is closed to new replies.