I get the following error
Notice: Undefined variable: prepared_stmt in “// Fetch the result”
My code is:
// The prepared statement
$sql = $pdo->query('SELECT * FROM table1 WHERE answer LIKE :answer');
while ($row = $sql->fetch())
{
echo $row['name'] . "n";
}
// Prepare, bind, and execute the query
$prepared_stmt->bind_param(':answer', $searchString);
$prepared_stmt->execute();
// Fetch the result
$result = $prepared_stmt->get_result();
if ($result->num_rows === 0) {
// No match found
echo "No match found";
// Kill the script
exit();
} else {
// Process the result(s)
while ($row = $result->fetch_assoc()) {
echo "<b>Qn Number</b>: ". $row['qnumber'] . "<br />";
echo "<b>Question</b>: ". $row['questionr'] . "<br />";
} // end of while loop
} // end of if($result->num_rows)
Could someone help me out?