Catchable fatal error: Object of class mysqli_result could not be converted to string

不想你离开。 提交于 2019-12-17 05:15:08

问题


Trying to get my first multi-table MySQL database but i've gut an error I just can wrap my head around. Can someone please suggest an approach before I toss my computer out a window?

Setup

I have two tables:

  1. clients which has rows: *id, tourbk_id, tourstart, roomtype1, client_name*
  2. tourprices which has rows: *id, tour_id, tourstart, roomtype, roomprice*

Goal

I'm intending for the following query to look, in the clients table for the tour the client wishes to purchase, compare the tour date + tour name + room type in the client table, and echo the price.

My fubar Query

    $tourquery = "SELECT t.roomprice 
         FROM clients c, tourprices t 
         WHERE c.roomtype1 = t.roomtype 
         AND c.tourstart = t.tourstart
         AND c.tourbk_id = t.tour_id"; 
$tourresult = $db->query($tourquery); 

echo '<strong>',"Per room amount:  ",'</strong>'.$tourresult. "";

$tourresult->free();

As-is, the result is just an error stating: Catchable fatal error: Object of class mysqli_result could not be converted to string

any help is much appreciated.


回答1:


The query() function returns a resource, you'll want fetch a record from what's returned from that function. Look at the examples on this page to learn how to print data from mysql



来源:https://stackoverflow.com/questions/13020298/catchable-fatal-error-object-of-class-mysqli-result-could-not-be-converted-to-s

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!