title: php mysql connection get error message
body: <p>this is my first php code , i am trying to connect to a database with user name = "root" and password = "root"</p>
  
  <p>i have a connection file called <code>dbConnection.php</code> 
  as following :</p>
  
  <pre><code>&lt;?php
  echo "in connection file";
  $hostname = "localhost";
  $username = "root";
  $password = "root";
  $db = "ledDB";
  echo "&lt;br&gt; db-connection : vars definde ";
  
  
  //connection to the database
  $conn = mysql_connect($hostname, $username, $password)
    or die("Unable to connect to MySQL");
  echo "Connected to MySQL&lt;br&gt;";
  echo "db-connection : initilize connection ";
  mysql_select_db($db);
  echo "db-connection : connection done";
  // Check connection
  
  echo "Connected successfully";
  ?&gt;
  </code></pre>
  
  <p>and i call it in a file called what.php :</p>
  
  <pre><code>&lt;?php
  echo "Hello";
  include "dbConnection.php";
  echo "ohhhh";
  ?&gt;
  </code></pre>
  
  <p>this returns status code 500 which is internal server error</p>
  
  <p>but i want to know what is the error to fix it how can i get the error message ?</p>
  
  <p>i tried </p>
  
  <p>$conn = mysql_connect($hostname, $username, $password)
    or die("Unable to connect to MySQL");</p>
  
  <p>but it is not returning any thing.</p>
  
  <p>can any one help me please ?</p>