0

Why my page doesn't work anymore after I added this code in:

<?php 
    $conn = mysqli_connect($host, $user, $pw, $db);
    if ($conn == false) {
        die("Es konnte keine Verbindung zur Datenbank hergestellt werden");
    }
?>

The error which I get is:

ERR_EMPTY_RESPONSE

If I uncomment this code then it works.

How can I solve this?

Mahendra Gunawardena
  • 1,918
  • 5
  • 25
  • 44
Cihat
  • 805
  • 1
  • 7
  • 17

3 Answers3

-1

change your code to this:

 <?php
$servername = "localhost";
$username = "username";
$password = "password";

// Create connection
$conn = new mysqli($servername, $username, $password);

// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
?> 
Blueblazer172
  • 551
  • 2
  • 14
  • 43
-1

Do it like this, hope it will work

$conn = new mysqli($host, $user, $pw, $db);
if ($conn->connect_error) {
   die("Connection failed: " . $conn->connect_error);
}
Waleed Ahmed
  • 1,094
  • 9
  • 16
-2

First you should check your database connectivity code, recheck the dbconfig php file. assign correct values for config db.

Check Blueblazer172 answer. it will help you.

Sathishkumar
  • 337
  • 2
  • 7
  • 15