 <p>First, you should not be using the MySQL extension. It has been deprecated. You should be using PDO or MySQLi. I recommend the former.</p> <p>Here's an example of a simple delete statement</p> <pre><code>&lt;?php session_start(); // you'll need this to access anything in $_SESSION // enable error reporting for development ini_set('display_errors', 'On'); error_reporting(E_ALL); if (!isset($_SESSION['username'])) { throw new Exception('No username in session'); } $pdo = new PDO('mysql:host=localhost;dbname=ubiquiblog;charset=utf8', 'labuser', 'Labuser1'); $pdo-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $stmt = $pdo-&gt;prepare('DELETE FROM `user_details` WHERE `username` = ?'); $stmt-&gt;bindParam(1, $_SESSION['username']); $stmt-&gt;execute(); printf('Deleted %d row(s) for username "%s"', $stmt-&gt;rowCount(), $_SESSION['username']); </code></pre>