title: WHERE NOT EXISTS - MYSQL/PHP
body: <p>I can't get my NOT EXISTS mysql statement to work and it's driving me mad now:</p>
  
  <pre><code>$ancestors = mysql_query('
      SELECT * FROM comments e
          WHERE 
              ancestors = "' . $comment["id"] . '" AND 
              user_id != "' . $user-&gt;user_object["id"] . '" AND
                  NOT EXISTS
                      (
                          SELECT  null 
                          FROM    notifications d
                          WHERE   d.target_id = e.id
                      )
  ', $database-&gt;connection_handle);
  </code></pre>
  
  <p>Any ideas?</p>
  
  <p>ERROR:</p>
  
  <pre><code>Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /&lt;&gt;/&lt;&gt;/functions.php on line 785
  Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /&lt;&gt;/&lt;&gt;/functions.php on line 785
  Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /&lt;&gt;/&lt;&gt;/functions.php on line 785
  Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /&lt;&gt;/&lt;&gt;/functions.php on line 785
  Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /&lt;&gt;/&lt;&gt;/functions.php on line 785
  Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /&lt;&gt;/&lt;&gt;/functions.php on line 785
  Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /&lt;&gt;/&lt;&gt;/functions.php on line 785
  Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /&lt;&gt;/&lt;&gt;/functions.php on line 785
  Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /&lt;&gt;/&lt;&gt;/functions.php on line 785
  </code></pre>
  
  <p>Line 785:</p>
  
  <pre><code>    while($reply = mysql_fetch_array($ancestors, MYSQL_ASSOC)){
  </code></pre>
  
  <p>If I do this:</p>
  
  <pre><code>$ancestors = mysql_query('SELECT * FROM ' . $database-&gt;db_prefix . 'comments 
      WHERE    
          ancestors = "' . $comment["id"] . '" AND 
          user_id != "' . $user-&gt;user_object["id"] . '"', 
          $database-&gt;connection_handle
  );
  </code></pre>
  
  <p>It returns my results i expect.</p>
  
  <p>the notifications table does contain an entry</p>
  
  <p>mysql var dump =</p>
  
  <pre><code>string(46) "Table 'whatever_co.comments' doesn't exist"
  </code></pre>
  
  <p>//SOLVED:::
  ' . $database->db_prefix . ' was missing from my table selectors.</p>