-1

I'm getting an undefined index notice, but can't figure out how to fix it.

Notice: Undefined index: id in /home/jharvard/vhosts/localhost/html/book_details.php on line 10

This is the code that's having problems:

    // query for the listing
$listing = query("SELECT name, author, id, edition, price, course, date FROM books WHERE submission = ?", $_GET["submission"]); 

// query for the email of the seller
$seller = query("SELECT email FROM users WHERE id = ?", $listing["id"]);

Can anyone help? Thank you very much.

Harry M
  • 1,848
  • 3
  • 21
  • 37

1 Answers1

1

The problem is that the array returned from your first query, $listing doesn't have an element with the key id.

I suspect this would happen if there was no record in the database for whatever was passed in as the submission GET parameter. Hard to say for sure though without knowing how the query() function was written.

Eric Petroelje
  • 59,820
  • 9
  • 127
  • 177