Click here to Skip to main content
15,392,078 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
<?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
<?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.
Posted
Updated 16-Feb-19 1:28am
v3

1 solution

Look at the MySQL documentation for the previous method call[^] where it explains what return value you will receive if the request fails.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900