Delete from check box

Hi guys,
can some one help me understand why the code is not deleting from my database. I have an inbox with messages and checkbox beside them that the user can check and then press the delete button.
But it doesn’t work and I’ve been going at it for quite a while now with no results. I would appreciate it if someone could tell me where my mistake is.

Thanks.


<form name="delete" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data">
<table width="97%" border="0" align="center" cellpadding="4">
          <tr>
            <td width="3%" align="right" valign="bottom"><img src="images/red_arrow.jpg" width="16" height="17" alt="Messages" /></td>
            <td width="97%" valign="top"><input type="submit" name="deleteBtn" id="deleteBtn" value="Delete" />
              <span id="jsbox" style="display:none"></span>
            </td>
          </tr>
      </table>
        <table width="96%" border="0" align="center" cellpadding="4">
          <tr>
            <td width="4%" valign="top">
            <input name="toggleAll" id="toggleAll" type="checkbox" onclick="toggleChecks(document.myform.cb)" />
            </td>
          </tr>
        </table>

This second part comes after some php code where I extract messages from database and present them to user along side the check boxs:


<td width="4%" valign="top" bgcolor="#CBE4F8">
    <input type="checkbox" name="cb<?php echo $row['id']; ?>" id="cb" value="<?php echo $row['id']; ?>" />
            </td>
</form>

The deleting part:


if (isset($_POST['deleteBtn'])) {
    foreach ($_POST as $key => $value) {
        $value = $value;
		if ($key != "deleteBtn") {
                   $sql = mysql_query("DELETE FROM mailbox WHERE id='$value' LIMIT 1");
	 
		}
    }
	header("location: x-civ-inbox.php");
}

don’t worry about it guys.
I haven’t slept for a while and keep on making stupid mistakes.

I forgot to connect to the mysql database, but since I didn’t add or die(mysql_error()); I didn’t know what the problem was for a while now.

Advice for other beginners like me:
Never forget to add " or die(mysql_error());" to your query so you can understand the problem you’re having. (It can save you hours of podering)