Php 页面显示不正确
我有下面的代码。直到最后一点,它运行良好。在//Close Main while循环注释之后,它似乎刚刚关闭并停止显示页面的其余部分,我似乎不知道为什么Php 页面显示不正确,php,mysql,loops,while-loop,Php,Mysql,Loops,While Loop,我有下面的代码。直到最后一点,它运行良好。在//Close Main while循环注释之后,它似乎刚刚关闭并停止显示页面的其余部分,我似乎不知道为什么 <?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_c
<?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'); ?>
为什么会这样;在}之后请删除
} // Close Main while loop
此处出现相同错误:
if($row['opened'] == "0"){
$textWeight = 'msgDefault';
} else {
$textWeight = 'msgRead';
};
您添加了一些分号;两个循环结束后都不需要使用的卷括号}
应该是
}
$fr_id = $row['from_id'];
而且
};// Close Main while loop
一定是
}// Close Main while loop
只是一个提醒。虽然您的bug似乎已经被彻底解决,但我建议您使用一个IDE来检测这些类型的问题。这样你就不会在职业生涯的剩余时间里寻找分号了。这是到Aptana的链接,Aptana是一个代码编辑器,有很多内置的错误检测功能。基本上,红线会在包含基本错误的行下弹出,比如缺少一条;或祝你好运,伙计
错误在上面:首先:尝试删除;php代码中的}之后会更好。打开错误报告'ini_setdisplay_errors,on;错误报告全部`两个都删除了,但仍然无法工作:/奇怪的一个:你可以在大括号后加分号,而不用PHP抛出任何表。@Fabio我按照建议更改了它,但没有任何区别,直到没有解决问题:Dang。无论哪种方式,我都可以保证它将为您节省数周的调试时间。尝试此方法后出现问题什么样的问题?请在PHP error_reportingE_ALL中启用错误报告功能;编辑您的帖子,这样我们就可以看到您当前的代码了;在scriptright的顶部启用了它,没有得到我能看到的任何错误,也没有得到任何错误日志。很遗憾,我没有访问我的php.ini的权限
}// Close Main while loop
$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!