After migrating from PHP 4.3.10 to 5.2.8 I'm receiving an "undefined index" error from the following code...

<?php
while($row = mysql_fetch_array($result)){?>
  <input id="yard_<?php echo $row['yard_id'];?>" type="checkbox" name="yard_list[]" value="<?php echo $row['yard_id'];?>" checked>
  <label for="yard_<?php echo $row['yard_id'];?>"><?php echo $row['yard'];?></label><br>
<?php
}?>

I know the mysql result is valid since it works fine in PHP4.

I realize this is a little messy and should have been written a little neater. But it is old code that I wrote long ago. My problem is I have this style of coding sprinkled throughout my apps and it would be a real task to find every occurrence of it.

Windows 2003 > Apache 2.x > MySql 3.x

Thanks

    To help debug, try a print_r() or var_dump() of $row within the while loop to see what array indexes actually exist.

      Write a Reply...