I am fairly new to web programming but I know quite a bit. I am making a private messaging system but I am getting an error:
Catchable fatal error: Object of class mysqli_result could not be converted to string in C:\xampp\htdocs\message\send.php on line 26
This is the code:
$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')");
What am I doing wrong, I have checked and there are values in the database. Also I have checked and I am using mysqli all around and not mixing mysql and mysqli. Any help would be greatly appreciated. Thanks.
Edit: Full code below:
<?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>";
}
}
?>