WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] $wpdb outside wordpress (again) (2 posts)

  1. jnhghy
    Member
    Posted 2 years ago #

    Hi, I'm using wordpress 3.4.1 and I have to extract some data from outside wordpress with a php file that is used by an ajax code. So I read a lot of posts telling me to include wp_db.php, wp_load.php, wp_config.php also to add some lines in wp_config.php, all this obvious didn't worked.
    At this point it will require lots of steps to turn the debugging on and to search for errors because the results are included in a dropdown and so on. So my humble question would be: Is anybody, using $wpdb outside the wordpress 3.4.1, kind enough to share the exact code that he/she used to enable the $wpdb global variable?
    Any help will be appreciated.
    Regards

  2. jnhghy
    Member
    Posted 2 years ago #

    Ok so after allot of tries I got the code to work, it seems I had issues with some ajax/javascript code (can't explain yet what was wrong with it...) the only file I included was :
    <?php require_once( $_SERVER['DOCUMENT_ROOT'] . '/wp-load.php' ); ?>
    and then I declared the global variable wpdb :
    <?php global $wpdb; ?>
    and it worked. I found some good extra info here if anybody needs it :)
    Regards

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags