错误:类mysqli的对象无法转换为字符串

错误:类mysqli的对象无法转换为字符串

问题描述:

I know that this question has been asked several times on this platform, however, none of them is able to solve my problem.

I am getting this error from the code below.

//This is working
$edition=mysqli_query($con,"select Price from books where Name='$book'");

//This is showing an error. The query is working when I run it on phpmyadmin.
//$edition=mysqli_query($con,"select Price from books where Name='$book' and Edition='$edition'");

//I am using mysqli_fetch_assoc to store it in $row and use the answer for later.
$row = mysqli_fetch_assoc($edition);

Let me know the problem and solution. Thanks in advance. :)

我知道这个问题在这个平台上被多次询问过,但是,他们都没有能够解决我的问题 问题。 p>

我从下面的代码中收到此错误。 p>

  //这是有效的
 $ edition = mysqli_query($ con,“选择图书中的价格= Name ='$ book'”); 
 
 // 这显示错误。 当我在phpmyadmin上运行它时,查询正在运行。
 // $ edition = mysqli_query($ con,“从书籍中选择价格,其中Name ='$ book'和Edition ='$ edition'”); 
 
 /  /我正在使用mysqli_fetch_assoc将其存储在$ row中并稍后使用该答案。
 $ row = mysqli_fetch_assoc($ edition); 
  code>  pre> 
 
 

让我知道 问题和解决方案。 提前致谢。 :) p> div>

Here we go then :)

Considering in your working example the variable $book already been used, my bet would be on the only other variable $edition. I was thinking if you could debug the code and check the value assigned to it just before using it to make your query, you could confirm if it is a acceptable type.