WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] $wpdb outside wordpress (again)

[Resolved] $wpdb outside wordpress (again)

  • 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

Viewing 1 replies (of 1 total)
  • 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

Viewing 1 replies (of 1 total)
  • The topic ‘[Resolved] $wpdb outside wordpress (again)’ is closed to new replies.
Skip to toolbar