0

Why am i getting this error? Object of class mysqli_result could not be converted to string on line 19 What is the error?

<?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";
}}
?>
Dharman
  • 30,962
  • 25
  • 85
  • 135
user3245415
  • 65
  • 1
  • 1
  • 4

1 Answers1

1

This line here:

$array= array("$exec");

Is causing a string cast. The error says you can't do that. When you put a string in double quotes (including the empty string) you are telling the parser to check for variables in that string and substitute them. In order to be able to do that PHP has to be able to cast them to a string type. stdClass variables do not have this option.

Zarathuztra
  • 3,215
  • 1
  • 20
  • 34