My site use to work fine. But today for some reason pages with mysqli_num_rows takes a very long time to load. I can visit the page but it takes a long time to load. When it loads there are no errors but the error file in the root directory have the following error:

Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given

There is no problem with my internet connection because other pages load fast and do not send reports to the error file. This is my first time encountring this problem.
Here is the code for the error line:

function fetch_rows($sql){

    global $con;

    $q = mysqli_query($con, $sql);
    return mysqli_num_rows($q);

}

I have tested the query on PhpMyAdmin and it works fine. But for some reason it takes time to load. I have even checked if the database has a lot of records, but it doesn't I have also emptied it.

Have any of you ran into the same error. Or understands the problem?

Thanks

Either it can’t connect to the database or there is an error in the SQL query. The query is failing for some reason or another.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.