-1

I am new to PHP and it is showing

"warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given"

My Code is :

<?php
include_once 'Conn.php';
 $qry="select * from sumit";
  $res=  mysqli_query($GLOBALS['link'],$qry);
echo '<table border="5">';
echo '<tr><th>Empno</th><th>Name</th><th>Adress</th><th>Salary</th></tr>';

while($r= mysqli_fetch_array($res))
    {
        echo "<tr><td>$r[0]</td><td>$r[1]</td><td>$r[2]</td><td>$r[3]</td></tr>";
    }  
    echo '</table>'; 
halfer
  • 19,824
  • 17
  • 99
  • 186
Sandeep
  • 1
  • 1

1 Answers1

0

Incidentally - though this doesn't solve your problem it might help when it comes to accessing records. If you use mysqli_fetch_object it makes it much easier to retrieve records imho. As an example:

include 'conn.php';
$con=$GLOBALS['link'];

if( is_object( $con ) ){
    $sql='select * from `city` limit 10';
    $res=mysqli_query( $con, $sql );

    if( $res ){
        while( $rs = mysqli_fetch_object( $res ) ) echo '<div>'.$rs->Name. ' '.$rs->CountryCode.' '.$rs->District.' '.$rs->Population.'</div>';
    }
    mysqli_free_result( $res );
    mysqli_close( $con );
    $con=null;
}
Professor Abronsius
  • 33,063
  • 5
  • 32
  • 46