Skip to content Skip to sidebar Skip to footer

Undefined Offset: 1

In my current PHP script this error comes up: Undefined offset: 1 My code is here: $query = 'SELECT item_id, username, item_content FROM updates ORDER BY update_time DESC

Solution 1:

Instead of

$row['item_content'] = strip_tags($matches[1]);

Try

if (isset($matches[0]) && isset($matches[0][1]))
  $row['item_content'] = strip_tags($matches[0][1]);
else$row['item_content'] = '';

Solution 2:

the error is on this line:

$row['item_content'] = strip_tags($matches[1]);

Solution 3:

As Neal said, there is a problem on that line. It seems that $matches[1] is undefined (i.e. there are no mathces, or there is only 1 match, $matches[0]). Make sure your table is working correctly.

Post a Comment for "Undefined Offset: 1"