导致内容页面内容消失的代码

时间:2010-09-17 20:35:09

标签: php

以下代码导致我正在处理的页面返回空白页面。页面上还有其他代码可以返回内容,如果我注释掉下面的代码,它会发生。下面的代码中是否有任何错误?

提前致谢,

约翰

$querysub = mysql_query("SELECT subcheck FROM submission WHERE submissionid = $submissionid");
$result = mysql_query($querysub);
if (!$result) {
    die 'Could not run query: ' . mysql_error();
}
else{
$subcheck = mysql_result($result, 0);
}

if($uid = $submittor)
{

if($subcheck = 1)
{

echo '<div class="commentnotify">You submitted item story and you have chosen to receive emails when someone comments on it.<a href="http://www...com/.../comments/commentnotifystop.php?submission='.urlencode($row["title"]).'&submissionid='.$row["submissionid"].'&url='.$row["url"].'&countcomments='.strtoupper($row["countComments"]).'&submittor='.$row["username"].'&submissiondate='.$row["datesubmitted"].'&dispurl='.$row["displayurl"].'">Click here to stop.</a></div>';


} else {
   echo '<div class="commentnotify">You submitted this item and you have chosen not to receive emails when someone comments on it.<a href="http://www...com/.../comments/commentnotifystart.php?submission='.urlencode($row["title"]).'&submissionid='.$row["submissionid"].'&url='.$row["url"].'&countcomments='.strtoupper($row["countComments"]).'&submittor='.$row["username"].'&submissiondate='.$row["datesubmitted"].'&dispurl='.$row["displayurl"].'">Click here to start.</a></div>';


} else {

} 

3 个答案:

答案 0 :(得分:1)

您在=条件中指定了分配运算符if,而您需要comparison operator==):

if($uid = $submittor)

应该是:

if($uid == $submittor)

if($subcheck == 1)

此行之后您还缺少结束括号}

echo '<div class="commentnotify">You submitted this item and you have chosen not to receive emails when someone comments on it.<a href="http://www...com/.../comments/commentnotifystart.php?submission='.urlencode($row["title"]).'&submissionid='.$row["submissionid"].'&url='.$row["url"].'&countcomments='.strtoupper($row["countComments"]).'&submittor='.$row["username"].'&submissiondate='.$row["datesubmitted"].'&dispurl='.$row["displayurl"].'">Click here to start.</a></div>';

答案 1 :(得分:0)

您不能拥有两个else块。但我想在这种情况下嵌套只是一个问题:

if($uid = $submittor)
{
    if($subcheck = 1)
    {
        echo '<div class="commentnotify">You submitted item story and you have chosen to receive emails when someone comments on it.<a href="http://www...com/.../comments/commentnotifystop.php?submission='.urlencode($row["title"]).'&submissionid='.$row["submissionid"].'&url='.$row["url"].'&countcomments='.strtoupper($row["countComments"]).'&submittor='.$row["username"].'&submissiondate='.$row["datesubmitted"].'&dispurl='.$row["displayurl"].'">Click here to stop.</a></div>';
    } else {
       echo '<div class="commentnotify">You submitted this item and you have chosen not to receive emails when someone comments on it.<a href="http://www...com/.../comments/commentnotifystart.php?submission='.urlencode($row["title"]).'&submissionid='.$row["submissionid"].'&url='.$row["url"].'&countcomments='.strtoupper($row["countComments"]).'&submittor='.$row["username"].'&submissiondate='.$row["datesubmitted"].'&dispurl='.$row["displayurl"].'">Click here to start.</a></div>';

    }  // <-- added this one
} else {

}

顺便说一下:您使用的是assignment operator =,而不是像==这样的comparison operator。赋值运算符生成指定的值。因此,表达式$uid = $submittor返回$submittor的值,$subcheck = 1返回1

答案 2 :(得分:0)

它缺少if($ uid = $ submittor){...}的最后一个括号。然后你收到一个错误,但你的服务器似乎无法显示它们,显示一个空白页面。