gpt4 book ai didi

php - 解锁的论坛帖子说已锁定?

转载 作者:行者123 更新时间:2023-11-30 01:19:47 25 4
gpt4 key购买 nike

好吧,抱歉发了这么多帖子。无论如何,我已经创建了整个代码文件; view_topic.php,这只是显示论坛帖子。我知道它很困惑并且不在 mysqli 中,一旦我完成此页面,我将重写整个代码。无论如何,先解决问题。当您访问任何主题时,无论锁定还是未单击,它总是会说:“抱歉,此帖子已锁定。”没有错误消息。我花了一整天的时间试图找到代码中的错误,并且我转向互联网寻求指导。这是完整的代码,如果您需要其他内容请告诉我:

<?php
require_once 'core/init.php';
// get value of id that sent from address bar
$id=$_GET['id'];
$sql="SELECT * FROM `forum_question` WHERE id='$id'";
$result=mysql_query($sql);
$rows=mysql_fetch_array($result);
if (!$result) { // add this check.
die('Invalid query: ' . mysql_error());
}
$thisql = "SELECT `locked` FROM `forum_question` WHERE `id`='$id'";
$mythisql = mysql_query($thisql);
$mythisql1 = mysql_fetch_array($mythisql);
if ($mythisql1 === false) { // add this check.
die('Invalid query: ' . mysql_error());
}
?>

<table width="700" align="center" class="outer">
<tr>
<td><table width="100%">
<tr>
<td class="back"><a href="mainforum.php">Back to Forum Home?</a></td>
</tr>
<tr>
<td><center><h3>
<?php
echo $rows['topic'];
?>
</h3></center></td>
</tr>

<tr>
<td align="right"><?php
if ($user_data['username'] === $rows['name']) {
?>
<form action="lock.php" method="post">
Lock? <input type="checkbox" name="lock" value="1" />
<input type="hidden" name="id" value="<?php echo $rows['id']; ?>" />
<input type="submit" value="Submit">
</form>
<?php
} ?>
</td>
</tr>
<tr>
<td><?php echo $rows['detail']; ?></td>
</tr>

<tr>
<td class="forumreply">By <a href=""><?php echo $rows['name']; ?></a>, On <?php echo $rows['datetime']; ?>
</tr>
</table></td>
</tr>
</table>
<BR>

<?php
$tbl_name2="forum_answer"; // Switch to table "forum_answer"
$sql2="SELECT * FROM $tbl_name2 WHERE question_id='$id'";
$result2=mysql_query($sql2);
while($rows=mysql_fetch_array($result2)){
?>

<table width="700" align="center" class="outer">
<tr>
<td><table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr><tr>
<td><?php echo $rows['a_answer']; ?></td>
</tr>
<td class="forumreply">By <a href=""><?php echo $rows['a_name']; ?></a>, On <?php echo $rows['a_datetime']; ?></td>
</tr>
</table></td>
</tr>
</table><br>

<?php
}


$sql3="SELECT view FROM `forum_question` WHERE id='$id'";
$result3=mysql_query($sql3);
$rows=mysql_fetch_array($result3);
$view=$rows['view'];

// if have no counter value set counter = 1
if(empty($view)){
$view=1;
$sql4="INSERT INTO `forum_question`(view) VALUES('$view') WHERE id='$id'";
$result4=mysql_query($sql4);
}

// count more value
$addview=$view+1;
$sql5="update `forum_question` set view='$addview' WHERE id='$id'";
$result5=mysql_query($sql5);
?>
<?php
if (logged_in() === true) {
if ($mythisql1['locked']===0) {
?>
<BR>
<table width="400" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<form name="form1" method="post" action="add_answer.php">
<input type="hidden" value="<?php echo $user_data['username']; ?>" name="a_name">
<td>
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td valign="top"><strong>Reply</strong></td>
<td valign="top">:</td>
<td><textarea name="a_answer" cols="45" rows="3" id="a_answer"></textarea></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input name="id" type="hidden" value="<?php echo $id; ?>"></td>
<td><input type="submit" name="submit" value="Submit"> <input type="reset" name="Submit2" value="Reset"></td>
</tr>
</table>
</td>
</form>
</tr>
</table>
<?php
} else {
echo "Sorry, this post is locked.";
}
}
ob_end_flush();
?>

如果有人能解决我的问题,我将永远感激不已。谢谢。

最佳答案

我看不到你的数据,所以这是一个猜测

使用 onyl ==0 而不是 ===0

if (logged_in() === true) {
if ($mythisql1['locked']==0) {
?>

或者如果$mythisql1['locked']是一个字符串

if (logged_in() === true) {
if ($mythisql1['locked']=='0') {
?>

关于php - 解锁的论坛帖子说已锁定?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18679104/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com