title: trouble with sql query in wordpress
body: <p>I'm using the exec php plugin to have php code inside my pages. I've imported a table into the wordpress db and copied my original query over into a page but I can't seem to get it working. </p>
  
  <p>I can't tell what's wrong because there is no sql error thrown onto the page, all it does is stop executing once it reached the query.</p>
  
  <pre><code>$query = "SELECT * FROM 'classSchedule' ORDER BY 'age' ASC";
  $result = mysql_query ($query, $link) or die (mysql_error());
  
  $num_rows = mysql_num_rows ($result);
  if ($num_rows != "0")
  {
      echo "Select a Class";
      while ($row = mysql_fetch_array($result))
      {
          $day = $row['day'];
          $time = $row['time'];
          $class = $row['class'];
          $age = $row['age'];
          $level = $row['level'];
  
          echo "(Age: $age) $day $time $class Level: $level";
      }
  }
  </code></pre>
  
  <p>I've also tried testing with example code in the wpdb codex but even that isn't working.</p>
  
  <pre><code>$mylink = $wpdb-&gt;get_row("SELECT * FROM $wpdb-&gt;wp_links WHERE link_id = 2");
  echo $mylink-&gt;link_id;
  </code></pre>
  
  <p>Someone please help! I'm using wordpress 3.1.</p>
  
  <p><strong>EDIT</strong>
  Okay I've solved it by adding global $wpdb to the top of the code.</p>