I have this imported database in phpmyadmin with two tables and I am using codeanywhere. The tables are simple: First table i20_vrste(id, naziv), Second table i20_zivotinje(id, id_vrste, ime, starost, bolesna)
So, the connection file contains:
<?php
$servername="localhost";
$username="root";
$password="";
$conn=mysqli_connect($servername, $username, $password);
?>
and then my second file with included connection, sql query looks like this:
<?php
$sql="select * from i20_vrste,i20_zivotinje where i20_vrste.id=i20_zivotinje.id_vrste";
$rez=mysqli_query($conn,$sql);
while($niz=mysqli_fetch_array($rez)){
$id=$niz['id'];
$id_vrste=$niz['id_vrste'];
$ime=$niz['ime'];
$starost=$niz['starost'];
$bolesna=$niz['bolesna'];
$naziv=$niz['naziv'];
if($bolesna==1){$bolesna="da";} else {$bolesna="ne";}
echo "$id$naziv$ime$starost$bolesna";
?>
When I run it, I want to see the data from imported database but it pops this error
mysqli_fetch_array()
expects parameter 1 to be mysqli_result, boolean given in.
Why is this happening and what can I do to resolve this error ?
What I have tried:
I know that problem is in sql query probably, but please notice that I am a total beginner in php and I could use some help.