2

我有下面的代码。它运行良好,直到最后一点。它似乎刚刚关闭并在// Close Main while loop评论后停止显示页面的其余部分,我似乎无法弄清楚原因。

    <?php
//show everything
error_reporting(E_ALL);

//using php.ini and ini_set()
ini_set('error_reporting', E_ALL);

require_once('header.tpl');

$my_id = '19';
mysql_connect("localhost","*********","*********") or die (mysql_error());
    mysql_select_db("*********") or die (mysql_error());
    ?>
    <!-- Navbar/popouts/notloggedin end -->
    <script language="javascript" type="text/javascript">
    function toggleChecks(field) {
        if (document.myform.toggleAll.checked == true){
              for (i = 0; i < field.length; i++) {
                  field[i].checked = true;
              }
        } else {
              for (i = 0; i < field.length; i++) {
                  field[i].checked = false;
              }     
        }

    }
    $(document).ready(function() { 
    $(".toggle").click(function () { 
      if ($(this).next().is(":hidden")) {
        $(".hiddenDiv").hide();
        $(this).next().slideDown("fast"); 
      } else { 
        $(this).next().hide(); 
      } 
    }); 
    });
    function markAsRead(msgID) {
        $.post("markAsRead.php",{ messageid:msgID, ownerid:<?php echo $my_id; ?> } ,function(data) {
            $('#subj_line_'+msgID).addClass('msgRead');
           // alert(data); // This line was just for testing returned data from the PHP file, it is not required for marking messages as read
       });
    }
    </script>
    <style type="text/css">
    .hiddenDiv {
        display:none
    }
    #pmFormProcessGif {
        display:none
    }
    .msgDefault {
        font-weight:bold;
    }
    .msgRead {
        font-weight:100;
        color:#666;
    }
    </style>

    <div class="container">
    <div class="row"> 
      <!-- /Welcome text -->
      <div class="span12">
        <div class="navbar navbar-inverse" style="position: static;">
          <div class="navbar-inner">
            <div class="container"><a class="btn btn-navbar" data-toggle="collapse" data-target=".navbar-inverse-collapse"><span class="icon-bar"></span> <span class="icon-bar"></span><span class="icon-bar"></span></a>
              <div class="nav-collapse collapse navbar-inverse-collapse">
                <ul class="nav">
                  <li><a href="#">Inbox</a></li>
                  <li><a href="#">Sent</a></li>
                  <li><a href="#">Deleted</a></li>
                  <form class="navbar-search pull-left" action="">
                    <input type="text" id="inbox_search" class="search-query span2" placeholder="Search Emails" />
                  </form>
                </ul>
                <ul class="nav pull-right">
                  <li><a href="#"><i class="icon-file icon-white"></i></a></li>
                  <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown"> <i class="icon-wrench icon-white"></i></a>
                    <ul class="dropdown-menu">
                      <li><a href="#">Create New Folder</a></li>
                      <li><a href="#">Message Templates</a></li>
                    </ul>
                  </li>
                </ul>
              </div>
            </div>
          </div>
          <!-- /navbar-inner --> 
        </div>
      </div>
    </div>
    <div class="row">
      <div class="span12">
        <table class="fulltable">
          <tr>
            <td class="fulltable_topbar" colspan="2"></td>
          </tr>
          <tr>
            <td class="fulltable_title"><div></div></td>
          </tr>
          <tr>
            <td class="fulltable_content" style="padding-top:10px"><div> 
                <!-- START THE PM FORM AND DISPLAY LIST -->
                <form name="myform" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data">
                  <table width="94%" border="0" align="center" cellpadding="4">
                    <tr>
                      <td width="3%" align="right" valign="bottom"><img src="images/crookedArrow.png" width="16" height="17" alt="Develop PHP Private Messages" /></td>
                      <td width="97%" valign="top"><input type="submit" name="deleteBtn" class="btn btn-small btn-invese" id="deleteBtn" value="Delete" />
                        <span id="jsbox" style="display:none"></span></td>
                    </tr>
                  </table>
                  <table width="96%" border="0" align="center" cellpadding="4" style="background-image:url(images/headerStrip.jpg); background-repeat:repeat-x; border: #999 1px solid;">
                    <tr>
                      <td width="4%" valign="top"><input name="toggleAll" id="toggleAll" type="checkbox" onclick="toggleChecks(document.myform.cb)" /></td>
                      <td width="20%" valign="top">From</td>
                      <td width="58%" valign="top"><span class="style2">Subject</span></td>
                      <td width="18%" valign="top">Date</td>
                    </tr>
                  </table>
                  <?php
    ///////////End take away///////////////////////
    // SQL to gather their entire PM list
    $sql = mysql_query("SELECT * FROM private_messages WHERE to_id='$my_id' AND recipientDelete='0' ORDER BY id DESC LIMIT 100");

    while($row = mysql_fetch_array($sql) **or die(mysql_error())**){ <error was the or die!

        $date = strftime("%b %d, %Y",strtotime($row['time_sent']));
        if($row['opened'] == "0"){
                $textWeight = 'msgDefault';
        } else {
                $textWeight = 'msgRead';
        }
        $fr_id = $row['from_id'];    
        // SQL - Collect username for sender inside loop
        $ret = mysql_query("SELECT id, username FROM members WHERE id='$fr_id' LIMIT 1");
        while($raw = mysql_fetch_array($ret)){ $Sid = $raw['id']; $Sname = $raw['username']; }

    ?>
                  <table width="96%" border="0" align="center" cellpadding="4">
                    <tr>
                      <td width="4%" valign="top"><input type="checkbox" name="cb<?php echo $row['id']; ?>" id="cb" value="<?php echo $row['id']; ?>" /></td>
                      <td width="20%" valign="top"><a href="<?php echo $Sname; ?>"><?php echo $Sname; ?></a></td>
                      <td width="58%" valign="top"><span class="toggle" style="padding:3px;"> <a class="<?php echo $textWeight; ?>" id="subj_line_<?php echo $row['id']; ?>" style="cursor:pointer;" onclick="markAsRead(<?php echo $row['id']; ?>)"><?php echo stripslashes($row['subject']); ?></a> </span>
                        <div class="hiddenDiv"> <br />
                          <?php echo stripslashes(wordwrap(nl2br($row['message']), 54, "\n", true)); ?> <br />
                          <br />
                          <a href="javascript:toggleReplyBox('<?php echo stripslashes($row['subject']); ?>','<?php //echo $my_uname; ?>','<?php echo $my_id; ?>','<?php echo $Sname; ?>','<?php echo $fr_id; ?>','<?php //echo $thisRandNum; ?>')">REPLY</a><br />
                        </div></td>
                      <td width="18%" valign="top"><span style="font-size:10px;"><?php echo $date; ?></span></td>
                    </tr>
                  </table>
                  <hr style="margin-left:20px; margin-right:20px;" />
                  <?php
    }// Close Main while loop
    ?>
                </form>
                <!-- END THE PM FORM AND DISPLAY LIST --> </div></td>
          </tr>
          <tr>
            <td class="fulltable_bottom" colspan="2"></td>
          </tr>
        </table>
      </div>
    </div>
    </body>
    </br>
    </br>
    <?php require_once('footer.tpl'); ?>
4

4 回答 4

0
 $sql = mysql_query("SELECT * FROM private_messages WHERE to_id='$my_id' AND recipientDelete='0' ORDER BY id DESC LIMIT 100");

while($row = mysql_fetch_array($sql) **or die(mysql_error())**){ <error was the or die!

错误在上面:)

于 2013-06-01T13:58:39.187 回答
0

只是一个提醒。虽然您的错误似乎已被彻底解决,但我建议您购买一个可以检测这些类型问题的 IDE。这样你就不会在你的职业生涯的剩余时间里都在寻找分号。这是 Aptana 的链接,它是一个具有大量内置错误检测功能的代码编辑器。基本上红线会在包含基本错误的行下方弹出,例如缺少;). 祝你好运伙计。

http://www.aptana.com/

于 2013-05-30T21:52:49.087 回答
0

为何 ; 在 } 之后(请删除)

   } // Close Main while loop

这里同样的错误:

 if($row['opened'] == "0"){
            $textWeight = 'msgDefault';
    } else {
            $textWeight = 'msgRead';
    };
于 2013-05-30T20:16:12.670 回答
0

您在两个循环 closin 花括号之后添加了一些分号;(不需要)}

};   
$fr_id = $row['from_id'];   

应该

}   
$fr_id = $row['from_id'];   

并且

};// Close Main while loop

必须

}// Close Main while loop
于 2013-05-30T20:17:13.847 回答