[Solved] PHP Notice: Undefined offset


The error

Notice: Undefined offset

is in essence saying that you have attempted to reference a value of an array that does not exist.

Reviewing your code, there are two possible instances where this can happen, first $_POST['checkbox'] and second $checked[$i].

You can resolve this error by something like this

if (isset ($_POST['submit']))
{
   $checked = isset($_POST['checkbox']) ? $_POST['checkbox'] : null;
   if (is_array($checked))
   {
     foreach ($checked as $check)
     {
        $result = mysql_query("UPDATE trace SET status="Delivered" WHERE id='$check'") or die(mysql_error());
     }
   }
}

Note the above code should not be used in production as it is not secure.

Note also that mysql_ functions are deprecated. Use PDO or mysqli for database queries.

2

solved PHP Notice: Undefined offset