mysqli_result类的对象无法转换为字符串

时间:2014-02-10 03:13:46

标签: php html http

为什么我收到此错误?  类mysqli_result的对象无法在第19行转换为字符串 错误是什么?

<?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 offername, description, payout, offerid FROM offers";
$exec= $mysqli->query($offername);
if (mysqli_num_rows($exec) == 0){
echo "No Offers Yet";
}else{
$array= array("$exec");
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";
}}
?>

1 个答案:

答案 0 :(得分:1)

这一行:

$array= array("$exec");

导致字符串强制转换。错误说你做不到。当您将字符串放在双引号(包括空字符串)中时,您告诉解析器检查该字符串中的变量并替换它们。为了能够做到这一点,PHP必须能够将它们转换为字符串类型。 stdClass变量没有这个选项。