I have no idea why this is not returning anything. I'll show the code and talk through the steps I've taken.
if (isset($_GET['observation'])) {
require_once("../func/connect.php");
$query = "SELECT * FROM observations WHERE option = ?";
$stmt = $db->prepare($query);
$stmt->bindValue(1, $_GET['observation']);
$stmt->execute();
$row = $stmt->fetch(PDO::FETCH_ASSOC);
echo $row['question'];
} else {
echo 'nope';
}
$row
dumps a false boolean, $row['question']
is null.
I've wrote about a million queries and don't have a clue why this doesn't work.
Database table observations
consists of id
, question
& option
and the bindValue
is correct to match a string in the database.
However, it returns null.