因此,我有一个数据库,程序可以正常运行,并且除我尝试获取数据库下定义的“ forum_name”并将其设置为“ Title”的所有内容外,所有其他功能都可以正常运行。如果我单击将我带到该帖子或论坛页面的链接,几乎可以在forum_name下得到内容,并将其打印为Title。
这是db_connect.php
<?php
$db = new mysqli("localhost", "root", "","forum") or die("ERROR: With Connecetion");
?>
这是重置:
<?php
session_start();
require"db_connect.php";
//get the page id
if(isset($_GET['id']) &&is_numeric($_GET['id'])){
$id = $_GET['id'];
}else{
die("Error! Does not exist!");
}
//check if Valid Id
$idCheck = $db->query("SELECT * FROM forum_tabl WHERE forum_id = 'id'");
if($idCheck->num_rows !==0){
die("error");
}
$row = $idCheck->fetch_object();
$sql = "SELECT post_id, post_title FROM forum_post WHERE forum_id? AND type= 'o'";
if($query = $db->prepare($sql)){
$query->bind_params('s', $id);
$query->bind_result($post_id, $post_title);
$query->execute();
$query->store_result();
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title><?= $row->forum_name?></title>
</head>
<body>
<div id="container">
<!-- Theres content that will go here -->
</div>
</body>
</html>
我认为问题出在这方面。
$idCheck = $db->query("SELECT * FROM forum_tabl WHERE forum_id = 'id'");
并且您必须按以下方式替换它。
$idCheck = $db->query("SELECT * FROM forum_tabl WHERE forum_id = '$id'");
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句