title: Remove mysqli_connect() (HY000/2002) Warning and send error via JSON Object
body: <p>This is My PHP code.    </p>
  
  <pre><code>&lt;?php
       $objRes= new \stdClass();
     if(mysqli_connect_errno($con=mysqli_connect("localhost","root","","mydb"))){
      $objRes-&gt;response="ConOrDbFailure";
      $myjson=json_encode($objRes);
      echo $myjson; 
        die();
     }
          ?&gt;
  </code></pre>
  
  <p>Here is my XAMPP status. <strong>I have intentionally stopped MYSQL service</strong>. For testing purposes.</p>
  
  <p><a href="https://i.stack.imgur.com/HEQ9J.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HEQ9J.png" alt="enter image description here"></a></p>
  
  <p>Here is my output in <a href="https://chrome.google.com/webstore/detail/postman/fhbjgbiflinjbdggehcddcbncdddomop?hl=en" rel="nofollow noreferrer">POSTMAN</a> if the <code>Mysql</code> is off. It shows no warning or error if <code>mysql</code> is on. </p>
  
  <p>Now my requirement is to remove the warning, while mysql is off. Because I need to parse the <code>JSON object</code> in <code>Android</code>. </p>
  
  <p><a href="https://i.stack.imgur.com/qWXdK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qWXdK.png" alt="enter image description here"></a></p>