这句话有什么不对,因为它没有打印结果并显示空白页面我问了同样的问题,但几小时前差点不大但没有得到正确的解决方案
这是代码
if(isset($_GET['ID'])){
$page_id = $_GET['ID'];
$select_query = $con->prepare("select ID, Title, image, Cost, Vid, content from mobs where ID=?");
$select_query->execute()
$select_query->bind_result($post_id, $post_title, $post_image, $post_cost, $post_vid, $post_content);
while ($select_query->fetch())
echo $post_id ,"<br>",
$post_title;
{
答案 0 :(得分:-2)
您忘记将$_GET["ID"]
与您的查询进行参数化:
if($stmt = $con->prepare("SELECT ID, Title, image, Cost, Vid, content FROM mobs WHERE ID=?")){
$stmt->bind_param("i", $_GET["ID"]); /* This is the part you're missing from your original post */
$stmt->execute();
$stmt->bind_result($post_id, $post_title, $post_image, $post_cost, $post_vid, $post_content);
while($stmt->fetch()){ /* And I fixed your fetching of arrays */
printf("%s<br>", $post_title); /* JUST SET WHAT YOU WANT TO OUTPUT HERE */
} /* END OF WHILE LOOP */
} /* END OF PREPARED STATEMENT */