获取&显示数据库错误
我正在尝试编写一个简单的流,从 mysql 字段传输所有内容。但我当前的脚本绝对没有显示任何内容......没有错误,没有任何内容。如下:
include("user_sytem_scripts/connect.php");
$sql_updates = mysql_query("SELECT item_id, username, item_content, update_time FROM updates ORDER BY update_time DESC LIMIT 30") or die("Query failed with error: ".mysql_error());
while($row = mysql_fetch_array($sql_updates)){
$update_id = $row["item_id"];
$update_username = $row["username"];
$item_content = $row["item_content"];
$update_time = $row["update_time"];
$updatestream = '
<table style="background-color:#FFF; border:#999 1px solid; border-top:none;" cellpadding="5" width="100%">
<tr>
<td width="90%" valign="top" style="line-height:1.5em;">
<span class="liteGreyColor textsize9">' . $update_time . ' <a href="profile.php?id=' . $update_username . '"><strong>' . $username . '</strong></a> via <em></em></span><br />
' . $item_content . '
</td>
</tr></table>'; }
然后在 HTML 中使用:
但正如我所说,我绝对什么也没得到。任何人都可以发现任何可能导致此问题的错误或一般错误吗?谢谢:D
I am trying to write a simple stream, streaming everything from a mysql field. But my current script shows absolutely nothing.. no errors, nothing. Here it is:
include("user_sytem_scripts/connect.php");
$sql_updates = mysql_query("SELECT item_id, username, item_content, update_time FROM updates ORDER BY update_time DESC LIMIT 30") or die("Query failed with error: ".mysql_error());
while($row = mysql_fetch_array($sql_updates)){
$update_id = $row["item_id"];
$update_username = $row["username"];
$item_content = $row["item_content"];
$update_time = $row["update_time"];
$updatestream = '
<table style="background-color:#FFF; border:#999 1px solid; border-top:none;" cellpadding="5" width="100%">
<tr>
<td width="90%" valign="top" style="line-height:1.5em;">
<span class="liteGreyColor textsize9">' . $update_time . ' <a href="profile.php?id=' . $update_username . '"><strong>' . $username . '</strong></a> via <em></em></span><br />
' . $item_content . '
</td>
</tr></table>'; }
Then down in the HTML I use: <?php echo $updatestream ?>
But as i said i get absolutly nothing.. Can anyone spot any errors or general mistakes that would cause this? Thanks :D
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我会检查以下内容:
您还应该将:
$updatestream = '
更改为$updatestream .=
以便附加文本,在当前 while 循环中,您将覆盖最后一个$updatestream值。
I would check the following:
You should also change:
$updatestream = '
to$updatestream .=
so that you append text, in the current while loop you'll overwrite the last$updatestream
value.首先,您需要在 while 循环之前初始化 $updatestream,($updatestream = ""),然后在循环内将其更改为 $updatestream .= "the string"。您可能想在最后重复您的结果,有时我们会忘记一些小事情。
First you need to initialize $updatestream,($updatestream = ""), before the while loop, then inside the loop you change it to $updatestream .= "the string". You might want to echo your result at the end, sometimes we forget the little stuff.