I'm working on an assignment for school which involves using PHP to generate a table of SQL results. I'm having a problem converting the results of my query. This is my error message:
Catchable fatal error: Object of class mysqli_result could not be converted to string
Here is the relevant part of my code:
$q = "SELECT pages.pageid,pages.pagetitle,pagetype.pagetypename,stylesheets.stylename
FROM pages
INNER JOIN stylesheets
ON pages.styleid=stylesheets.styleid
INNER JOIN pagetype
ON pages.pagetypeid=pagetype.pagetypeid
ORDER by pages.".$sortBy." ".$sortDirection;
print("<p>Query: ".$q."</p>\n");
$r = mysqli_query($db_link,$q);
$n = mysqli_num_rows($r);
print("<p>$r</p>");
My only theory is that maybe since I'm using an inner join with multiple tables there's something additional I need to do? I ran the query the code displayed in the MySQL server and it worked fine and returned the right results.