mysqli exception handling
// we can go with die function, and some mysqli function like // mysqli_num_rows $con=mysqli_connect("localhost","root","","employeeDB") or die('Unable to connect'); $sql="select * from employee where id = 1"; $result=mysqli_query($con,$sql) or die(mysqli_error()); if ($result){ // this will return the number of rows in result set $numRos=mysqli_num_rows($result); if($numRos > 0){ $data = mysqli_fetch_array($result); print_r($data); }else{ print "No data found"; } }