title: Unknown column 'chenzhen' in where clause
body: <p>I have a PHP script that connects to a MySQL database using the mysqli extension to search for Blog Posts based on Username or ID. I created a VIEW called <code>BlogSearch</code> that uses joins form other tables to aggregate the information I need together that is represented like this:</p>
  
  <p></p>
  
  <p>The Tables it pulls from are called <code>Profiles</code> that has the User information, <code>BlogPosts</code> and <code>BlogCategory</code></p>
  
  <p>Everytime I search I get the error:
  <code>Unknown column 'chenzhen' in 'where clause'</code></p>
  
  <p>The PHP code I'm using below:</p>
  
  <pre><code>require 'database.php'; 
  
          $query = "SELECT * FROM BlogSearch";
  
    echo &lt;&lt;&lt;EOF
  &lt;form method='post' action='' style="padding: 30px 0;"&gt;
          &lt;table cellspacing="0" border="0" style="float: left;"&gt;
          &lt;tr&gt;
          &lt;td&gt;Search Blog Posts by Username/ID&lt;/td&gt;
          &lt;td&gt;&lt;input type="text" id="search" name="search" style="width: 300px;"/&gt;&lt;/td&gt;
          &lt;td&gt;&lt;input type="submit" id="submit_button" value="Search" name="submit_button" style="float: right;" /&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;/table&gt;
      &lt;/form&gt;
  EOF;
  
          if(isset($_POST['submit_button'])) 
      {
          $search_term = $_POST['search'];
            $query = $query . " WHERE `NickName` LIKE '%$search_term%' OR ID = $search_term ";
  
  
          // run the query and store the results in the $result variable.
          $result = $mysqli-&gt;query($query) or die(mysqli_error($mysqli));
  
      }
  
      if ($result) {
  
    // create a new form and then put the results
    // into a table.
  
  
  
    echo "&lt;form method='post' action='delete.php' style='clear: both;'&gt;"; 
    echo "&lt;table cellspacing='0' cellpadding='15'&gt;
          &lt;th width='5%'&gt;
          &lt;input type='checkbox' id='allcb' onclick='checkAll(this)' name='allcb' /&gt;Check All
          &lt;/th&gt;
          &lt;th width='10%'&gt;User&lt;/th&gt;
          &lt;th width='85%'&gt;Blog Post Title&lt;/th&gt;
          ";
  
  
    while ($row = $result-&gt;fetch_object()) {
  
          $title = substr($row-&gt;PostCaption,0,50);
          $id = $row-&gt;PostID;
          $user = $row-&gt;NickName;
  
          //put each record into a new table row with a checkbox
      echo "&lt;tr&gt;
              &lt;td&gt;&lt;input type='checkbox' name='checkbox[]' id='checkbox[]'  value=$id /&gt;
              &lt;td&gt;$user&lt;/td&gt;
              &lt;td&gt;$title&lt;/td&gt;
           &lt;/tr&gt;"; 
  
      }
  
      // when the loop is complete, close off the list.
      echo "&lt;/table&gt;&lt;p&gt;&lt;input id='delete' type='submit' class='button' name='delete' value='Delete Selected Items'/&gt;&lt;/p&gt;&lt;/form&gt;";
  }
  </code></pre>
  
  <p>I don't know why it's even identify the username as a column. Can anyone point me in the right direction to fix this?</p>
  
  <p>Thanks in advance.</p>