I am trying to get rows from the database using MySQl prepared statements and get result. However this is not working.
Please can someone see where I am going wrong? I have been trying solutions for hours but I can't get it to work. The page just doesn't load as if the query has failed.
$tag = trim($_GET['tag']);
$stmt = $mysqli->prepare('SELECT posts.* FROM tags JOIN posts ON posts.id = tags.post_id WHERE tag = ?');
$stmt->bind_param('s', $tag);
$stmt->execute();
$stmt->store_result();
$result = $stmt->get_result();
while ($row = $result->fetch_assoc()) {
echo $row['tag'];
}
$stmt->free_result();
$stmt->close();