2011-03-20 64 views
0

我正在嘗試編寫一個簡單的流,從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:<?php echo $updatestream ?>

但正如我所說,我得到什麼是絕對..任何人都可以發現,將導致此任何錯誤或失誤一般?謝謝:d

+0

如果您有錯誤登錄,錯誤將出現在Web服務器的錯誤日誌中。 – jterrace 2011-03-20 03:11:37

+1

你真的使用這個標題(*有沒有辦法檢查用戶屏幕分辨率?*),或者在stackoverflow數據庫中做了一些事情會感到困惑? – 2011-03-20 03:27:11

+0

僅供參考,PHP有一個叫做[stream](http://us2.php.net/manual/en/book.stream.php)的核心概念,你不在這裏使用它們。要小心,錯誤地使用這個術語可能會在以後引起混淆。 – Charles 2011-03-20 04:10:38

回答

0

我會檢查以下內容:

  1. 請問,當你手動運行它(在phpMyAdmin爲例)運行查詢?
  2. 你有沒有得到任何輸出?如果沒有,看起來你的外觀從DB獲得0結果。

你也應該改變:$updatestream = '$updatestream .=,使您追加文本,在當前while循環將會覆蓋最後$updatestream值。

0

首先,您需要在while循環前初始化$ updatestream,($ updatestream =「」),然後在循環內部將其更改爲$ updatestream。=「string」。你可能想在最後迴應你的結果,有時我們會忘記那些小東西。

echo $updatestream; 
相關問題