0

I'm getting an error saying

Fatal error: Array callback has to contain indices 0 and 1 in C:\xampp\htdocs\series\databases\index.php on line 10

Here's the little code that I have. I know I am not actually pulling anything from the database but can't go any further until I resolve this issue.

<?php 
require 'connect.inc.php';

$query = "SELECT `food`, `calories` FROM `food` ORDER BY `id`";
//$query_run = mysql_query($query);

if ($query_run = mysql_query($query)){

while ($query_row =  mysql_fetch_assoc($query_run)) {
$food = $query_row('food');  //Fatal error message for this line
$calories = $query_row('calories'); //When I comment out line 10 this gives an error too
}

} else {
echo mysql_error();
}

?>

If you want any more info let me know, I was following this tutorial that may be out of date.
So yeah, any ideas on how to resolve this? Thanks.

user2849976
  • 158
  • 1
  • 2
  • 10

1 Answers1

2
$query_row['food'];

You are using the wrong kind brackets, square brackets access array items.

Cornelius
  • 4,214
  • 3
  • 36
  • 55
guest
  • 36
  • 1