title: PHP variable as table name mysqli
body: <p>I'm working on at function that should be able to handle multiple tables, using <code>$variables</code>.</p>
  
  <p>But I get an syntax error..</p>
  
  <p>The code that works.</p>
  
  <pre><code>$query = "INSERT INTO table_com (tableID, komNAME, komDATE, komHTML, komSTATUS) 
  VALUES ('$pID','$name','$time','$kom','$status')";
  if(!$mysqli-&gt;query($query)) { die($mysqli-&gt;error); }    
  </code></pre>
  
  <p>and the code that don't</p>
  
  <pre><code>$sID = 'table':
  $query = "INSERT INTO '$sID'_com ('$sID'ID, komNAME, komDATE, komHTML, komSTATUS) 
  VALUES ('$pID','$name','$time','$kom','$status')";
  if(!$mysqli-&gt;query($query)) { die($mysqli-&gt;error); }
  </code></pre>
  
  <p>It is only the table and column <code>$variables</code> that don't work..
  Here is the my_sql_error:</p>
  
  <pre><code>You have an error in your SQL syntax; check the manual that corresponds to your 
  MySQL server version for the right syntax to use near ''diy'_com ('diy'ID, 
  komNAME, komDATE, komHTML, komSTATUS) VALUES ('1','cjkm,','1' at line 1
  </code></pre>
  
  <p>Are there any way around this problem?</p>