title: Check if MySQL server is running before retriving data from it
body: <p>What is the correct way of checking if the MySQL server is up and running before trying to retrieving data from it ?</p>
  
  <p>I'm using PHP and MySQLI in the object orientated way.</p>
  
  <p>I'm semi-new to MySQLI and managed to write something useful for my website. A voting system.</p>
  
  <p>I have some code on my website that retrieves data from the MySQL server and displays it on the website.</p>
  
  <p>This works fine as long at the MySQL server is up and running and are able to connect to it.</p>
  
  <p>But if i turn off the MySQL server or otherwise my PHP code is not able to connect to the SQL server my website hangs for a while until timeout and then part of my website is not displayed.</p>