Hi i'm trying to load database from Mysql serveer and keep getting this error now mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in C:\Users\Mirne\Desktop\Server\root\funkcie.php on line 15 . I have checked quite few posts but i don't see to find my mistake . Ty for help
<?php
global $X,$Y,$height,$weight,$key,$type,$text,$position;
function load() {
$servername = "localhost";
$username = "root";
$password = "xxxx";
$dbname = "web builder";
$link = mysqli_connect($servername, $username, $password, $dbname);
if (!$link) {
die("Connection failed: " . mysqli_connect_error());
}
$sql = "SELECT x, y, height, weight, key , type , text , position FROM suradnice";
$result = mysqli_query($link, $sql);
if (mysqli_num_rows($result) > 0) { ////////line15///////
while($row = mysqli_fetch_assoc($result)) {
$X=$row["x"] ;
$Y=$row["y"] ;
$height=$row["height"] ;
$weight=$row["weight"];
$key=$row["key"];
$type=$row["type"] ;
$text=$row["text"] ;
$position=$row["position"] ;
}
} else {
echo "error";
}
mysqli_close($link);
}
?>