Probably, it's the
if...else
above it:
if (isset($_POST['search'])) {
$searchTerm = $_POST['search'];
} else {
}
If "search" isn't set, then $searchTerm is never assigned a value, and doesn't exist.
Add a default value assignment above the
if
and it should work.
To prove it:
$x = 2;
if ($x == 3){
$searchTerm = 'Hello World';
} else {
}
echo $searchTerm;
Fails with your error, while:
$searchTerm = "DEFAULTED";
$x = 2;
if ($x == 3){
$searchTerm = 'Hello World';
} else {
}
echo $searchTerm;
Works fine.