0

I got above Error from below For Loop;

while($Row=mysql_fetch_array($qry)){
    $result_list[] = $Row;

}
foreach((array)$result_list as $Row) {
    $ID=$Row['ID'];
    $Name=$Row['name'];
    $has_acco = $Row['Accomodation'];
}
u_mulder
  • 54,101
  • 5
  • 48
  • 64
ndlelan
  • 11
  • 1
  • 3
  • `$result_list` is already __array__, there's no need to cast it to `array`. – u_mulder Dec 06 '18 at 09:46
  • 3
    Possible duplicate of [Reference - What does this error mean in PHP?](https://stackoverflow.com/questions/12769982/reference-what-does-this-error-mean-in-php) – Mohammad Dec 06 '18 at 09:47
  • 1
    This is quite straightforward, the lines of your array don't have `ID`. What does your array look like ? – Jules R Dec 06 '18 at 09:47
  • 2
    Please, post `print_r(result_list)`, I think your array don't have `ID` – Alberto Moro Dec 06 '18 at 09:50

1 Answers1

0

try code this way

while($Row=mysql_fetch_array($qry)){
    $ID=$Row['ID'];
    $Name=$Row['name'];
    $has_acco = $Row['Accomodation'];
}

no need extra for loop

Bhargav Chudasama
  • 6,928
  • 5
  • 21
  • 39