php 可捕获的致命错误:无法将类 mysqli_result 的对象转换为字符串
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13020298/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Catchable fatal error: Object of class mysqli_result could not be converted to string
提问by shane
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?
试图获得我的第一个多表 MySQL 数据库,但我遇到了一个错误,我只能回过头来。在我把电脑扔出窗外之前,有人可以建议一种方法吗?
Setup
设置
I have two tables:
我有两个表:
- clientswhich has rows: *id, tourbk_id, tourstart, roomtype1, client_name*
- tourpriceswhich has rows: *id, tour_id, tourstart, roomtype, roomprice*
- 具有行的客户:*id、tourbk_id、tourstart、roomtype1、client_name*
- Tourprices包含以下行:*id、tour_id、tourstart、roomtype、roomprice*
Goal
目标
I'm intending for the following query to look, in the clientstable for the tour the client wishes to purchase, compare the tour date + tour name + room type in the clienttable, and echo the price.
我打算在下面的查询来看看,在客户表的客户希望购买的旅游,比较在游览日游+姓名+房型客户表,和回声的价格。
My fubarQuery
我的fubar查询
$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
按原样,结果只是一个错误说明: 可捕获的致命错误:mysqli_result 类的对象无法转换为字符串
any help is much appreciated.
任何帮助深表感谢。

