Another problem I've come across is this one. I'm trying to call this function from another function but the SQL query is giving me this error:
Catchable fatal error: Object of class mysqli could not be converted to string in .....
I'm clueless as to why this keeps occurring. Could someone please explain to me why this fatal error wont go away? I'm using procedural statements.
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>";
}
}
mysqli_query ($dbc. $SQLanswered)
Shouldn't that be
mysqli_query ($dbc, $SQLanswered)
?
Looks like you're accidentally doing string concatenation.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.