我遇到的另一个问题就是这个问题。我试图从另一个函数调用此函数,但SQL查询给我这个错误:
捕获致命错误:类mysqli的对象无法转换为.....中的字符串
我对于为什么这种情况不断发生毫无头绪。有人可以向我解释为什么这个致命的错误不会消失吗?我正在使用程序性陈述。
function answered($you, $dbc)
{
$SQLanswered = "SELECT readcount FROM Faq WHERE sender = '$you' ";
$Ranswered = mysqli_query ($dbc. $SQLanswered)
or trigger_error("Query: $SQLanswered\n<br />MySQL Error: " . mysqli_error($dbc));
while($row = mysqli_fetch_assoc($Ranswered))
{
$answered[] = $row['readcount'];
}
mysqli_free_result($Ranswered);
for($i = 0; $i < sizeof($answered); $i++)
{
$num += $answered[$i];
}
if($num > 0)
{
echo " <a href='extrainfo.php'>($num answered)</a>";
}
}
答案 0 :(得分:2)
mysqli_query ($dbc. $SQLanswered)
不应该是
mysqli_query ($dbc, $SQLanswered)
看起来你不小心在进行字符串连接。