title: Query Wordpress Database outside of Wordpress files
body: <p>I am trying to access my Wordpress database from a file that is outside of the theme files.  However, I can't directly use the wp-config information because they change every day.  This results in the necessity of the global $wpdb variable. </p>
  
  <p>Could anyone provide some assistance in the way of accessing the database?</p>
  
  <p>Here's my code trying to gain access :</p>
  
  <pre><code>&lt;?php
  
   define('WP_USE_THEMES', false);
  require('../wp-blog-header.php');
  
  
   global $wpdb;
  
  ?&gt;
  </code></pre>
  
  <p>...</p>
  
  <pre><code>&lt;?php
  
  if(isset($_POST['post_variable'])) {
  $selected_post = $_POST['post_variable'];
  }
  
  elseif(isset($_GET['post_variable'])) {
  $selected_post = $_GET['post_variable'];
  }
  
  
  $sql1 = "SELECT * FROM wp_posts WHERE post_status = 'publish' AND post_type = 'home-messages' AND ID = '$selected_post'";
  $result1 = mysql_query($sql1) or die(mysql_error());
  while ($row1 = mysql_fetch_assoc($result1)) {
  $display_post_content = $row1['post_content'];
  $display_post_title = $row1['post_title'];
  
  }
  ?&gt;
  </code></pre>