2014-02-10 74 views
-1

類mysqli_result的對象無法轉換爲第27行的字符串 有人可以解釋如何解決此問題,錯誤描述,即時嘗試使虛擬PHP商店對於一個朋友而我試圖做的是顯示一系列優惠和他們的描述,我試圖做的是從數據庫中提取數據來列出優惠,代碼不斷說這個錯誤,有誰知道如何解決它?Cachable致命錯誤:mysqli_result類的對象無法轉換爲字符串

<?php 
//Offer Wall 
// Put your CPA Networks Virtual Currency Widget after the End of this first PHP 
//Segment 
include "mysqli_config.php"; 
?> 
<table> 
<tr> 
<th>Offer Name</th> 
<th>Description</th> 
<th>Payout</th> 
</tr> 
</table> 
<?php 
$offername= "SELECT * FROM offers WHERE active = 1"; 
$exec= $mysqli->query($offername); 
$array = array($exec); 
if (mysqli_num_rows($exec) == 0){ 
echo "No Offers Yet"; 
}else{ 
while (list($x, $y, $z, $a) = $array){ 
echo " <tr>\n " . 
" <td><a href=\"click.php?=$a\">Click Here to Open Offer</a></td>\n" . 
" <td>$z</td>\n" . 
" <td>$y</td>\n" . 
" <td>$x</td>\n"; 
}} 
?> 
+0

結帳這 - ?http://stackoverflow.com/questions/14573134/mysqli-mysqli-result-could-not-be-converted-to-string – Mediabeastnz

回答

0

X,Y,Z,A和0,1,2,3必須被改變,以獲得所需的結果,但是這是想法。錯誤在這一行:$ array = array($ exec);

<?php 
//Offer Wall 
// Put your CPA Networks Virtual Currency Widget after the End of this first PHP 
//Segment 
include "mysqli_config.php"; 
?> 
<table> 
<tr> 
<th>Offer Name</th> 
<th>Description</th> 
<th>Payout</th> 
</tr> 
</table> 
<?php 
$offername= "SELECT * FROM offers WHERE active = 1"; 
$exec= $mysqli->query($offername); 
//$array = array($exec); 
if (mysqli_num_rows($exec) == 0){ 
    echo "No Offers Yet"; 
}else{ 
    while ($array=mysqli_fetch_row($exec)){ 
    $a=$array[3]; 
    $x=$array[0]; 
    $y=$array[1]; 
    $z=$array[2]; 
    echo " <tr>\n " . 
     " <td><a href=\"click.php?=$a\">Click Here to Open Offer</a></td>\n" . 
     " <td>$z</td>\n" . 
     " <td>$y</td>\n" . 
     " <td>$x</td>\n"; 
}} 

>

相關問題