title: 'SQLSTATE[42S22]: Column not found: 1054 Unknown column 'id'
body: <p>Hi: I'm having trouble debugging some MySQL &amp; PHP code. </p>
  
  <p><strong>Background</strong></p>
  
  <ul>
  <li>Downloaded <a href="http://ajaxlivesearch.com/" rel="nofollow">http://ajaxlivesearch.com/</a> source code</li>
  <li>Followed instructions and enabled debugging</li>
  <li>Created a MySQL db with the following columns: list_ADDRESS, list_COMPANY, list_WEBSITE, list_INDUSTRY</li>
  <li>I know the db + connection work (I set up a small test file to connect &amp; spit out the tables that're in the db)</li>
  </ul>
  
  <p><strong>Issue</strong></p>
  
  <ul>
  <li>The search doesn't work and returns a 'Something went wrong' error</li>
  <li>With debugging enabled, the error_log file shows the following:</li>
  </ul>
  
  <blockquote>
    <p>[26-Aug-2015 06:37:42 UTC] PHP Fatal error:  Uncaught exception 'PDOException' with message 'SQLSTATE[42S22]: Column not found: 1054 Unknown column 'id' in 'field list'' in /public_html/inz/class/handler.php:85
    Stack trace:</p>
    
    <p>0 /public_html/inz/class/handler.php(85): PDO-prepare('SELECT COUNT(id...')</p>
    
    <p>1 /public_html/inz/ajax/process_livesearch.php(21): Handler::get_result('Telecom', 1, 5)</p>
    
    <p>2 {main}</p>
  </blockquote>
  
  <ul>
  <li>handler.php (around line 85) contains the following code:</li>
  </ul>
  
  <blockquote>
    <p>$db = DB::getConnection();</p>
    
    <p><em>//this is line 85//</em> $stmt = $db->prepare('SELECT COUNT(id) FROM ' . Config::USER_TABLE . ' WHERE ' . Config::SEARCH_COLUMN . ' LIKE :query');
    $search_query = $query.'%';</p>
    
    <p>$stmt->bindParam(':query', $search_query, PDO::PARAM_STR);</p>
    
    <p>$stmt->execute();</p>
    
    <p>$number_of_result = $stmt->fetch(PDO::FETCH_COLUMN);</p>
  </blockquote>
  
  <ul>
  <li><p>For ref, process_livesearch.php line 21 contains the following:</p>
  
  <pre><code>        $result = json_encode(Handler::get_result($_POST['ls_query'], (int) $_POST['ls_current_page'], (int) $_POST['ls_items_per_page']));
  </code></pre></li>
  </ul>
  
  <p>Does anyone know why it seems to be looking for a column called 'id' ? That's not specified anywhere in the config file, nor elsewhere in the code that i can see other than being mentioned on line 85 of handler.php...</p>