 <p>Don't single quote your table name, if anything use magic quotes (`)</p> <p>You should not be building the query by concatenating strings.</p> <p>To avoid potential issues with SQL injection, it would be wise to use prepared queries.</p> <p>I've just confirmed this on a mysql server</p> <pre><code>mysql&gt; delete from 'sessions' where `last_activity` = 0; ERROR 1064 (42000): 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 ''sessions' where `last_activity` = 0' at line 1 mysql&gt; delete from sessions where `last_activity` = 0; Query OK, 0 rows affected (0.00 sec) </code></pre>