【问题标题】:Cachable Fatal error: Object of class mysqli_result could not be converted to string [duplicate]可缓存致命错误:类 mysqli_result 的对象无法转换为字符串 [重复]
【发布时间】:2014-02-10 22:34:39
【问题描述】:

类 mysqli_result 的对象无法在第 27 行转换为字符串 有人可以解释如何解决这个问题,错误描述,我试图为朋友创建一个虚拟 PHP 商店我试图做的是显示报价列​​表及其描述,我试图做的是从数据库列出报价,代码一直说这个错误,有谁知道如何解决它?

  <?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";
}}
?>

【问题讨论】:

标签: php mysqli


【解决方案1】:

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";
}}

?>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-03-19
    • 2016-06-17
    • 2017-04-20
    • 2014-03-31
    • 1970-01-01
    • 2022-01-05
    相关资源
    最近更新 更多