我正在学习使用预准备语句从db获取内容。这是我拼凑在一起的代码,但它没有返回任何内容。
$question_id = strip_tags(mysqli_real_escape_string($conn, $_GET['id']));
$sql = "
SELECT
*
FROM
question_index
WHERE
id = ? AND
remove = '0' AND
active = '1' AND
publish_date <= '$current_time'
LIMIT
1
";
$stmt = $conn->prepare($sql);
$stmt->bind_param('i', $question_id);
$stmt->execute();
$result = $stmt->get_result();
while ($row = $result->fetch_assoc()) {
// Localize
foreach($row as $key=>$value) {
${$key} = $value;
}
// Current Question
$current_question = $question;
// Publish Date
$current_publish_date = date('F d, Y g:i A', strtotime($publish_date));
}