Zaheen
Zaheen

Reputation: 51

SELECT Query in php: Response Too Late

All other pages with same Database connection works fine, but this page takes 10-15 minutes to load.

It produces correct output but takes so long although this table "user" has only 2 records.

Am I missing something or making some mistake?

$conn = mysqli_connect("localhost","root","","myprojectdatabase");

if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}
$result = mysqli_query($conn, "SELECT * FROM user ");

while( false !== ($row = mysqli_fetch_assoc($result))){
    echo "<pre>";
    echo $row['username'];
}
$conn->close();

Upvotes: 0

Views: 73

Answers (1)

shubhangee
shubhangee

Reputation: 539

Try to use below code and see if it works for you

   $conn = mysqli_connect("localhost","root","","myprojectdatabase");
   if ($conn->connect_error) {
      die("Connection failed: " . $conn->connect_error);
   }
   $result = mysqli_query($conn, "SELECT * FROM user");
   while( false !=($row = mysqli_fetch_assoc($result)))
   {
     echo"<pre>";
     echo $row['username'];
   }
   $conn->close();

Upvotes: 1

Related Questions