mysqli_num_rows funktioniert nicht?

Hallo ich wollte etwas auf Strato hosten. Jedoch funktioniert mysqli_num_rows nicht.

Weiß jemand wie ich den Fehler beheben kann.

Hier die Fehler meldung:

Connected successfully Fatal error: Uncaught TypeError: mysqli_num_rows(): Argument #1 ($result) must be of type mysqli_result, bool given in /mnt/web016/e0/16/511052116/htdocs/cgi-bin/Inventar/index.php:28 Stack trace: #0 /mnt/web016/e0/16/511052116/htdocs/cgi-bin/Inventar/index.php(28): mysqli_num_rows() #1 {main} thrown in /mnt/web016/e0/16/511052116/htdocs/cgi-bin/Inventar/index.php on line 28

Und mein Code:

<?php session_start:
require_once('dbconnection.php');
$servername = "...";
$username = "...";
$password = "...";


// Create connection
$con = new mysqli($servername, $username, $password);


// Check connection
if ($con->connect_error) {
  die("Connection failed: " . $con->connect_error);
}
echo "Connected successfully";
error_reporting(E_ALL);
ini_set('display_errors', true);
ini_set('mysql.trace_mode', true);








//Code for Registration 
if(isset($_POST['signup']))
{
	$fname=$_POST['fname'];
	$lname=$_POST['lname'];
$sql=mysqli_query($con,"select id from users where fname='$fname'");
$row=mysqli_num_rows($sql);
if($row>3)
{
	echo "<script>alert('Artikel befindet sich schon 3 mal in der Truhe');</script>";
} else{


	$msg=mysqli_query($con,"insert into users(fname,lname) values('$fname','$lname')");
}
if($msg)
{
	echo "<script>alert('Erfolgreich Eingetragen');</script>";
}
}


?>


PHP, Strato