gpt4 book ai didi

PHP 无法将 SQL 结果转换为字符串?

转载 作者:太空宇宙 更新时间:2023-11-03 10:36:37 25 4
gpt4 key购买 nike

<分区>

<?php
$q = intval($_GET['q']);

$con = mysqli_connect('censored','censored','censored','db');
if (!$con) {
die('Could not connect: ' . mysqli_error($con));
}

mysqli_select_db($con,"db");
$sql="SELECT message FROM messages WHERE code = '".$q."'";
$result = mysqli_query($con,$sql);
$resultstring = (string)$result;

echo $resultstring;

mysqli_close($con);
?>

我试图将查询结果回显给用户,但是当此 PHP 通过 ajax 运行时,我收到此错误:

Recoverable fatal error: Object of class mysqli_result could not be converted to string in D:\xampp\htdocs\getmessage.php on line 12

现在我不明白这一点,因为我已经将 $result 转换为字符串。谢谢!

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com