簡體   English   中英

准備好的PHP語句沒有打印出來

[英]Prepared PHP statement not printing out

我有一個聲明,它從數據庫中獲取信息,然后在完全准備好后打印出來。但出於某種原因,我的腳本沒有打印出信息。 我在這個if語句中有它:

if($community == ''){ print $community . "\n\n" . "END" . "\n"; } else { print $community; echo "hi";}

這會在運行時打印出來:

()寫道:

但這就是打印出來的全部內容。 那是來自第8個$ community。= line。 所以,我的問題是,為什么它只打印出來()寫道:而不是所有的變量呢?

//  and ticker_symbol ='".$sym."'
    $c_sql = "SELECT message_id, subject, author, FROM_UNIXTIME(datestamp,'%m-%d-%Y') AS formatted_datestamp, forum_id, body, thread, user_id FROM phorum_messages WHERE user_id=13423720 ORDER BY datestamp DESC LIMIT 5";
    $c_result = mysql_query($c_sql,$connection) or die("Couldn't execute get query");

    // Declare Variables
    $body                   = $c_result['body'];
    $forum_id               = $c_result['forum_id'];
    $user_id                = $c_result['user_id'];
    $author                 = $c_result['author'];
    $formatted_datestamp    = $c_result['formatted_datestamp'];

    // Prepare the statement
    if ($c_result != "")  {
        $community .=  $forumPost = '<<<ENDL '. "\n";
        $community .= $body . "\n";
        $community .= 'ENDL;' . "\n";
        $community .= '$forumPost = stripBBCode(strip_tags($forumPost));' . "\n";
        $community .=  "\n";
        $community .= '<div class="comment">' . "\n";
        $community .= '<table cellspacing="0" cellpadding="0" border="0" class="reply"><tbody><tr>' . "\n";
        $community .= '<td width="90%"><b><a href="/emerging/forum/read.php?'.$forum_id.','.$user_id.'">'.$author.'</a> ('.$formatted_datestamp.') wrote:</b><br />' . "\n";
        $community .= '<p>'.iconv("ISO-8859-1//TRANSLIT", "UTF-8", $forumPost).'</p></td>' . "\n";

        $community .= '</tr></tbody></table>'. "\n";
        $community .= '</div>' . "\n";
    }

    // Print out the prepared statement
    if($community = ''){ print $community . "\n\n" . "END" . "\n"; } else { print $community;}

當您調用if($community = ''){您只有一個等號時,會將$community設置$community空字符串。

我認為你的意思是if($community == ''){

它應該具有雙重相等:

if($community == '')

使用單個=符號,您只需將一個空字符串分配給變量$community - 然后檢查它是否為true 空字符串評估為false ,因此您將進入else部分 - 並在此過程中丟失您的價值。

你只有一個=符號

你需要:

if($community == '') { etc...

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM