2013-07-31 56 views
-2

真的不知道怎麼了這裏,但它不是在頁面上返回任何東西..我慢慢地改變一切從MySQL到新的MySQLi庫MySQLi取回陣列返回null

<?php 
include_once "php_includes/db_conx.php"; 
$query = "SELECT * FROM testimonials ORDER BY id ASC LIMIT 32"; 
$result = mysqli_query($query) or die (mysqli_error()); 
while ($row = mysqli_fetch_array($result)){ 
    $testtitle = $row['testtitle']; 
    $testbody = $row['testbody']; 
    $compowner = $row['compowner']; 
    $ownertitle = $row['ownertitle']; 
    $compname = $row['compname']; 
    $compwebsite = $row['compwebsite']; 

    $testsList .= '<div class="gekko_testimonial testimonial gekko_testimonial_speech"> 
     <div class="gekko_main"><div class="gekko_headline">' . $testtitle . '</div> 
     <p>' . $testbody . '</p> 
     </div> 
     <div class="speech_arrow"></div> 
     <span class="gekko_who_client_name">' . $compowner . ' of ' . $compname . '</span> 
     <span class="gekko_who_job_title">' . $ownertitle . '</span> 
     <span class="gekko_who_website">View the Website... <a href="http://' . $compwebsite . '" target="_blank">' . $compwebsite . '</a></span> 
     </div>'; 
} 
?> 

任何幫助,不勝感激!我也是你<?php echo $testslists; ?>在我的HTML! 非常感謝 Phillip Dews

+0

首先,證明您完全連接到數據庫。你會怎麼做?你怎麼知道它的工作? – Cups

回答

1

mysqli_query需要連接成爲第一個參數。請密切關注mysqli函數,因爲它們中的很多需要連接作爲第一個參數。

$result = mysqli_query($con, $query) or die (mysqli_error()); 
+0

[mysqli or die,does it has die?](http://stackoverflow.com/a/15320411/285587) –

+0

排序非常感謝我所做的全部是添加 $ result = mysqli_query($ db_conx,$ query)或die(mysqli_error()); 給它! –

2

你唯一的問題是不足錯誤報告

error_reporting(E_ALL); 
ini_set('display_errors',1); 

就在你的代碼的頂部添加這些行,你會立即通知你的代碼的確切問題。

請注意,在生產服務器上,您必須關閉顯示錯誤並登錄