gpt4 book ai didi

PHP/SQL - mysqli_result 类的对象无法转换为字符串

转载 作者:行者123 更新时间:2023-12-04 14:52:16 24 4
gpt4 key购买 nike

<分区>

我是网络编程的新手,但我知道很多。我正在制作私有(private)消息系统,但出现错误:

Catchable fatal error: Object of class mysqli_result could not be converted to string in C:\xampp\htdocs\message\send.php on line 26

这是代码:

$check_conv=mysqli_query($con,"SELECT `hash` FROM `message_g` WHERE (`user_one`='$my_id' AND `user_two`='$user') OR (`user_one`='$user' AND `user_two`='$my_id')");

我做错了什么,我已经检查过,数据库中有值。我也检查过,我到处都在使用 mysqli,而不是混合使用 mysql 和 mysqli。任何帮助将不胜感激。谢谢。

编辑:完整代码如下:

<?php 
if(isset($_POST['submit'])){
$myusername=$_SESSION['myusername'];
$random=rand();
$my_id=mysqli_query($con,"SELECT `id` FROM `users` WHERE (`username`='$myusername')");
$user=$_GET['user'];
$check_conv=mysqli_query($con,"SELECT `hash` FROM `message_g` WHERE (`user_one`='$my_id' AND `user_two`='$user') OR (`user_one`='$user' AND `user_two`='$my_id')");
if(mysqli_num_rows($check_conv) == 1){
echo "<p>Conversation Already Started!</p>";
} else {
mysqli_query("INSERT INTO `message_g` (`user_one`, `user_two`, `hash`) VALUES ('$my_id','$user','$random')");
echo "<p>Conversation Started!</p>";
}
}
?>

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