Hi
can anyone help me with this error im getting? im trying to change this code from php to pdo and am having a problem with the delete code im getting this error Warning: Variable passed to each() is not an array or object in /home/a.php on line 37
thanks.

PHP Code:
<?php
require("db.php");
$query "SELECT invoicenumber FROM hostingpackage";
?>
<table width="400" border="0" cellspacing="1" cellpadding="0">
    <tr>
        <td>
            <form name="form1" method="post" action="">
            <table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC">
            <tr>
                <td bgcolor="#FFFFFF">&nbsp;</td>
                <td colspan="4" bgcolor="#FFFFFF"></td>
            </tr>
            <tr>
                <td align="center" bgcolor="#FFFFFF">#</td>
                <td align="center" bgcolor="#FFFFFF"><strong>Invoice Number</strong></td>
            </tr>
            <?php $stmt $db->prepare($query);
  
$result $stmt->execute($query_params);
  
$result $stmt->setFetchMode(PDO::FETCH_NUM);
while (
$rows $stmt->fetch($result)) { ?>
            <tr>
                <td align="center" bgcolor="#FFFFFF"><input name="need_delete[<? echo $rows['id']; ?>]" type="checkbox" id="checkbox[<? echo $rows['id']; ?>]" value="<? echo $rows['id']; ?>"></td>
                <td bgcolor="#FFFFFF"><? echo htmlspecialchars($rows['invoicenumber']); ?></td>
            </tr>
            <?php ?>
            <tr>
                <td colspan="5" align="center" bgcolor="#FFFFFF"><input name="delete" type="submit" id="delete" value="Delete"></td>
            </tr>
            <?php
   
if($_POST['delete']){
  
$i 0;
  while(list(
$key$val) = each($_POST['checkbox'])) {
    
$sql "DELETE FROM $tbl_name WHERE id='$val'";
    
mysql_query($sql);
    
$i += mysql_affected_rows();
  }
  if(
$i 0){
    echo 
'<meta http-equiv="refresh" content="0;URL=a.php">';
  }
}                
?>
            </table>
            </form>
        </td>
    </tr>
</table>