title: iOS- SQLITE_MISUSE error (code 21)
body: <p>I try Insert an array of objects into my database , all of them inserted successfully except last one , It give me this error  </p>
  
  <p>here is my code I use to insert into database </p>
  
  <pre><code>  - (int)insertWithQuery:(NSString *)query {
          sqlite3_stmt *statement;
          const char *dbpath = [databasePath UTF8String];
  
          if (sqlite3_open(dbpath, &amp;database) == SQLITE_OK) {
              const char *insert_stmt = [query UTF8String];
              if(sqlite3_prepare_v2(database, insert_stmt, -1, &amp;statement, NULL)!= SQLITE_OK){
  
                   NSLog(@"the error occurred here is %s ",sqlite3_errmsg(database));
                  return DATABASE_FAILED;
  
                   }
              int res = sqlite3_step(statement);
  
  
              if (res == SQLITE_DONE) {
                  return DATABASE_SUCCESS;
              } else if (res == SQLITE_CONSTRAINT) {
                  return DATABASE_ALREADY_EXISTS;
              } else {
                  return DATABASE_FAILED;
              }
              sqlite3_finalize(statement);
              sqlite3_close(database);
          } else {
              return DATABASE_FAILED;
          }
      }
  </code></pre>
  
  <p>The error Printed to me is </p>
  
  <blockquote>
    <p>near "3": syntax error</p>
  </blockquote>
  
  <p>my Passed query is look like </p>
  
  <pre><code>INSERT INTO report (report_id, student_id, report_title, report_body, from_date, to_date, timestamp) VALUES ("217", "1", "", "&lt;h3&gt;Hazem Taha Ghareeb &lt;small&gt;report&lt;/small&gt;&lt;/h3&gt;From: &lt;p&gt;2014-06-17 &lt;/p&gt; To: &lt;p&gt;2014-06-24 &lt;/p&gt;&lt;table&gt;&lt;thead&gt;&lt;th&gt;Exam&lt;/th&gt;&lt;th&gt;Date&lt;/th&gt;&lt;th&gt;Result&lt;/th&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;Java &lt;/td&gt;&lt;td&gt;2014-06-18 &lt;/td&gt;&lt;td&gt;138 &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;h3&gt;Absence&lt;/h3&gt;&lt;table&gt;&lt;thead&gt;&lt;th&gt;Date&lt;/th&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;2014-06-17 &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;2014-06-22 &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;2014-06-24 &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/body&gt;&lt;/html&gt;", "2014-06-17", "2014-06-24", "2014-06-24 12:23:58") 
  </code></pre>
  
  <p>The one have problem is </p>
  
  <pre><code>INSERT INTO report (report_id, student_id, report_title, report_body, from_date, to_date, timestamp) VALUES ("631", "1", "C class report4", "&lt;h3&gt;Hazem Taha &lt;small&gt;report&lt;/small&gt;&lt;/h3&gt;From: &lt;p&gt;30-01-2015 &lt;/p&gt; To: &lt;p&gt;30-01-2015 &lt;/p&gt;&lt;table&gt;&lt;thead&gt;&lt;th&gt;Exam&lt;/th&gt;&lt;th&gt;Date&lt;/th&gt;&lt;th&gt;Result&lt;/th&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td colspan="3"&gt; No exams records. &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;h3&gt;Absence&lt;/h3&gt;&lt;table&gt;&lt;thead&gt;&lt;th&gt;Date&lt;/th&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt; No absence records. &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/body&gt;&lt;/html&gt;", "2015-01-30", "2015-01-30", "2015-01-29 08:43:21”)
  </code></pre>
  
  <p>Any one know can help me</p>