title: SQLite3::query(): Unable to prepare statement: 1, unrecognized token ""
body: <p>I am trying to create a PHP search query that searches by each word from the database. But i get this error when search query is submitted.</p>
  
  <blockquote>
    <p>Warning: SQLite3::query(): Unable to prepare statement: 1, unrecognized token: "'%export%" in C:\xampp\htdocs\xport\searchresult.php on line 107</p>
  </blockquote>
  
  <p>Below is my code.</p>
  
  <p>For the search page </p>
  
  <pre><code>if (isset($_POST['mainSearch'])) 
  {
  
  if (!empty($_POST['mainSearch']))
  {
      $searchquery = $_POST['mainSearch'];
  
      $query = str_replace(" ", "+", $_POST['mainSearch']);
      header("Location: searchresult.php?mainSearch=" . $query);
  
  }
  
  }
  </code></pre>
  
  <p>Page to display search result.</p>
  
  <pre><code>if (isset($_GET["mainSearch"])) 
  {
    $condition = '';
    $query = explode(" ", $_GET['mainSearch']);
  
    foreach ($query as $text) 
    {
        $condition .= "question LIKE '%".SQLite3::escapeString($text)."%' OR answer LIKE '%".SQLite3::escapeString($text)."%'";
    }
    $condition = substr($condition, 0, -4);
  
    $sql_query = "SELECT * FROM questions WHERE " . $condition;
    $result = $db-&gt;query($sql_query);
  
    if ($result)
    {
        while ($row = $result-&gt;fetchArray(SQLITE3_ASSOC))
        {
             echo '&lt;div class="quesbox_2"&gt;
              &lt;div class="questitle"&gt;
                  &lt;h2&gt;'.$row["question"].'&lt;/h2&gt;
              &lt;/div&gt;
              &lt;div class="quesanswer"&gt;'.$row["answer"].'&lt;/div&gt;
          &lt;/div&gt;';
        }
    }
    else
    {
  
    }
    }
  </code></pre>
  
  <p>What is the reason for this error. I think its because the string is not properly escaped, if this is the reason how do i <code>mysqli_real_escape_string()</code> in <code>SQLite3</code> (this is the database i am using). If not, Please how do i fix this.</p>