PHP connecting to database fails without error : <p>I am trying to connect to databse on my server by using this code:</p>

<pre><code>&lt;?php
 $username = "username";
 $servername = "localhost";
 $password = "password";
 echo "Before connection";

 // Create connection
 $conn = new mysqli($servername, $username, $password);
 // Check connection
 if ($conn-&gt;connect_error) {
     die("Connection failed: " . $conn-&gt;connect_error);
 }
 echo "Connected successfully";
?&gt;
</code></pre>

<p>But code after <code>$conn = new mysqli($servername, $username, $password);</code> is not executing. When i try to echo anything after it I do not get output. Code before that line works as expected. I do not get any errors from php.</p>

<p>I am not sure what is problem. Could it be something server related? I did try to add:</p>

<pre><code>ini_set('display_errors',1);
 error_reporting(E_ALL); 
</code></pre>

<p>but it didn't help, no errors have been displayed.</p>

<p>I have been trying many things from stackoverflow (and other places) but they didnt help, some examples:</p>

<p><a href="https://stackoverflow.com/questions/16683337/connecting-to-a-mysql-database-from-php-error-but-no-error-shown">Connecting to a mysql database from php, error but no error shown?</a></p>

<p><a href="https://stackoverflow.com/questions/41878840/connection-of-mysql-with-php-not-working">Connection of MySQL with PHP not working</a></p>
