Good Afternoon,
I am currently working through a lab task for my course and the provided solution is giving me an error which I dont understand. The error is
Warning: Undefined array key "animal" in C:\xampp\htdocs\PE7045\week 6\zoo1.php on line 12
I know the cnnection to my DB is OK, I have used that script multiple times. I am just confused with the undefined array key.
Its coming from this code $animalID = $_REQUEST['animal'];
Should it not b asking for some user input with the $_Request?
Many thanks !
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Week 6 task 3-2</title>
</head>
<body>
<h1>Zoo - Display Name for One Animal</h1>
<p>
<?php
$animalID = $_REQUEST['animal'];
include('dbconn.php');
$sql = "SELECT Animalname FROM ANIMAL WHERE animalID=$animalID";
$queryresult = mysqli_query($conn, $sql);
//Generate link to update.php with Animal ID as parameter
if ($queryresult) {
$currentrow = mysqli_fetch_assoc($queryresult);
$name = $currentrow['Animalname'];
echo "\n\tName=$name";
}
mysqli_free_result($queryresult);
mysqli_close($conn);
?>
</p>
</body>
</html>