0

嗨,我的论坛评论表有问题。基本上我试图让用户阅读用户的帖子并对其发表评论,表单数据应该被插入到 mysql 中。

我需要插入的值是comment_id,它是用户的会话ID,而post_id是他们评论的帖子的ID和他们输入的内容。

出于某种原因,这没有被插入到 mysql 中,并且没有任何错误地提出我的回显成功消息。有人可以告诉我我哪里出错了。

谢谢

<?php
        $page_title = "Read Post";
        include('includes/header.php'); 
        include ('includes/mod_login/login_form2.php');  ?>

        <?php
        confirm_logged_in();



        if (isset ($_GET['post'])) {
        $forum_id = $_GET['post'];
    }

    ?>

    <?php include('includes/copyrightbar.php'); ?>
    <?
    $read_forum_set = read_forum_set();
            while ($forum = mysql_fetch_array($read_forum_set)) {?>
    <div class="modtitle">
    <div class="modtitle-text"><?php echo "{$forum['display_name']}"; ?>'s Forum Post</div>
    <? } ?>
    </div>

    <div class="modcontent57">


    <br /><br /><br/><br/>

    <div class="forum">
    <div class="forum-pic"><?php echo "<img src=\"data/photos/{$_SESSION['user_id']}/_default.jpg\" width=\"100\" height=\"100\" border=\"0\" align=\"right\" class=\"img-with-border-forum\" />";?>
    </div>

    <div class="message-links">
    <strong><a href="forum.php"><< Back to Forum</a>
    </div> 
    <br /><br /><br/><br/>
    <?php 

        $datesent1 = $forum['date_sent'];  ?>

    <?php
            $read_forum_set = read_forum_set();
            while ($forum = mysql_fetch_array($read_forum_set)) {
            $prof_photo = "data/photos/{$forum['user_id']}/_default.jpg";

            $result = mysql_query("UPDATE ptb_forum SET ptb_forum.read_forum='1' WHERE ptb_forum.id='$forum'") 
    or die(mysql_error()); 

    ?>
    <div class="message-date">
    <?php echo "".date('D M jS, Y  -  g:ia', strtotime($forum['date_sent'])).""; ?></div>



    <div class="img-with-border-frm-read"><?php echo "<a href=\"profile.php?id={$forum['from_user_id']}\"><img width=\"60px\" height=\"60px\" src=\"{$prof_photo}\"></a><br />"; ?></div>



    <?php echo "<div class=\"forum-content2\"><div class=\"forum_subject\"><strong>Subject:</strong></div><div class=\"forum_subject2\"><i>{$forum['title']}</i></div><div class=\"forum_body\"><strong>Post:<br/></strong></br ><i>{$forum['content']}</i></div></div>";?>



     <?php 
    // check if the review form has been sent
    if(isset($_POST['forum_comment']))
    {
        $content = $_POST['forum_comment'];
            //We remove slashes depending on the configuration
            if(get_magic_quotes_gpc())
            {
                    $content = stripslashes($content);
            }
            //We check if all the fields are filled
            if($_POST['forum_comment']!='')
            {


                {
                $sql = "INSERT INTO ptb_forum_comments (comment_id, post_id, content) VALUES (NULL, '".$_SESSION['user_id']."', '".$profile_id."', '".$content."');";
                mysql_query($sql, $connection);

                echo "<div class=\"infobox-profile4\"><strong>Thank You</strong> - Your review has been sent for approval.</div>";
            } }
    }

    ?> 


     <?php if(isset ($_SESSION['user_id'])) { ?>



    <div class="forum-comment-box">
    <form action="<?php $_SERVER['PHP_SELF'] ?>" method="post">
    <textarea name="forum_comment" id="forum_comment" style="resize:none; height:100px; width:543px;"></textarea><input type="submit" name="send_button" id="send_button" style="float:right; margin-right:30px; text-align:center;" value="Reply to {$message['display_name']}" /></form></div>

    <? } } ?>


          </div>
          </div>



    <?php include('includes/footer.php'); ?>
    </div>
4

1 回答 1

1

您在这里缺少一些表名:

$sql = "INSERT INTO ptb_forum_comments (comment_id, post_id, content) VALUES (NULL, '".$_SESSION['user_id']."', '".$profile_id."', '".$content."');";

如您所见,您有 3 个表名和 4 个值。

于 2013-02-05T19:10:19.740 回答