2010-02-24 40 views
0

在一个用户配置文件的工作,有一个评论框,使其他用户张贴在他们的个人资料的意见。我现在的工作,有一个动态的评论区一个取决于如果A.你是在寻找自己的个人资料B.看着别人的个人资料C.在所有未签署改变文本框。我怎样才能插入查询与两个if(isset报表?

我想实现“更新”现在,当你是你自己页面,在评论框中输入,然后输出到页面上的指定区域(将其输出到社区页面上,但尚未输出)

在此配置文件页面上,我有插入查询插入正常的评论就好(第一次插入查询),现在我试图添加第二个if(isset语句与第二个插入查询,并且在执行此操作时遇到问题。

它没有插入,页面在提交按钮被击中后加载空白。我是一个php btw新手。谢谢:

/* code chunk for the regular comments that is working just fine */ 

     if(isset($_POST['commentProfileSubmit']) && $auth) { 

     $query = "SELECT `Email` FROM `Users` WHERE `id` = '" . $prof->id . "'"; 
     $request = mysql_query($query,$connection) or die(mysql_error()); 
     $result = mysql_fetch_array($request); 

     $Email = $result['Email']; 


     $to = $Email; 
     $subject = "$auth->first_name $auth->last_name left you a comment"; 
     $message = "$auth->first_name $auth->last_name left you a comment: <br /><br /> <a href='http://www.blah.org/Profile.php?id=" . $prof->id . "'>Click here to view</a><br /><br />"; 
     $from = "blah <[email protected]>"; 
     $headers = 'MIME-Version: 1.0' . "\r\n"; 
     $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; 
     $headers .= "From: $from"; 
     mail($to, $subject, $message, $headers); 



     $query = "INSERT INTO `ProfileComments` 
           (`FromUserID`, 
            `ToUserID`, 
            `commentProfileBody`, 
            `status`, 
            `date`, 
            `time` 

            ) VALUES (

           '" . $auth->id ."', 
           '" . $prof->id ."', 
               '" . mysql_real_escape_string($_POST['ProfileComment']) ."', 
           'active', 
           '" . date("Y-m-d") . "', 
           '" . date("G:i:s") . "')"; 

    mysql_query($query,$connection); 

    /* code chunk that is not inserting the desired info into the db and loading the page blank when I hit submit */ 

     }elseif(isset($_POST['airwaveSubmit']) && $auth) { 

     $query2 = "INSERT INTO `Airwaves` 
          (`id`, 
          `body`, 
          `status`, 
          `date`, 
          `time` 

          ) VALUES (

          '" . $auth->id ."', 
          '" . $mysql_real_escape_string($_POST['body']) . "', 
          'active', 
          '" . date("Y-m-d") . "', 
          '" . date("G:i:s") . "')"; 

              mysql_query($query,$connection);  

      } 
     ?> 

    /* dynamic text/areas with dynamic submit buttons which is working how it should but want to include in case there is something on here that is causing the previous troubles */ 

<div id="commentBoxBlog"> 
<form name="CommentBox" method="post" action="Profile2.php?id=<?php echo $prof->id; ?>"> 
    <?php if($auth->id == $prof->id) { 
    echo "<div id='counter'> 
    <span id='counter_airway'>140 Character Limit</span> 
    </div>"; 
    echo "<textarea name='airwaveBody' class='round_10px' onkeyup='limit_length(this,140,\"counter_airway\");'></textarea> <input type='submit' name='airwaveSubmit' value='Exhale' class='post'/>";} elseif(!$auth) { 
echo "<textarea name='ProfileComment' class='round_10px' disabled>Please sign in to comment...</textarea>"; } elseif($auth->id != $prof->id) 
    echo "<textarea name='ProfileComment' class='round_10px'></textarea> 
    <input type='submit' name='commentProfileSubmit' value='Exhale' class='post' />"; 

    ?> 
    </form> 
</div> 
+0

有什么在PHP错误日志? – 2010-02-24 17:45:48

+0

错误日志已关闭。作为一个新手,我有没有影响我的网站的功能,一些枝节问题,但有很多的用户,它会显示的东西,这将使该网站看起来破碎,错误显示明智的。 – 2010-02-24 17:49:04

回答

2

你把SQL在名为$ QUERY2变量,但在你的mysql_query()调用将它发送到你使用一个变量名为$查询数据库。

+0

仍在加载页面空白而未插入。虽然这很好。谢谢 – 2010-02-24 22:21:43