title: Php connecting but failing to select a database
body: <p>I am having trouble getting php to connect to my mysql database on a shared hosting. This worked when it was on my MAMP local server.</p>
  
  <p>I get the following error:</p>
  
  <p>Error: No database selected Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in /hermes/bosnaweb03b/b2270/ipg.theburguersaredownco/cheval/main.php on line 34</p>
  
  <p>My db_connect php file:</p>
  
  <pre><code> &lt;?php
  $connect = mysqli_connect('theburguersaredownco.ipagemysql.com', 'user', 'password');
  if (!$connect) {
      die('Could not connect: ' . mysqli_error());
  }
  echo 'Connected successfully';
  mysqli_select_db('db_cheval'); 
  ?&gt;
  </code></pre>
  
  <p>I get the message: "Connected successfully", so I am assuming the connection to the database is established and therefore there are no issues with the mysql_connect function or any of its arguments (i.e. the user and password are correct etc...).</p>
  
  <p>my main.php file:</p>
  
  <pre><code>&lt;?php
    include 'db_connect.php';
    include 'header.php';
  
    error_reporting( E_ALL );
    ini_set( "display_errors", 1 );
    ?&gt;
  
  &lt;a id="roundLogo" href="index.php" class="not-active"&gt;&lt;/a&gt;&lt;div&gt;
  
  &lt;/div&gt;&lt;/a&gt;
  
  &lt;div id="subheader" class="notVisible"&gt;
  
    &lt;nav id="menu2"&gt;
      &lt;ul&gt;
    &lt;?php
        $query = mysqli_query($connect,"SELECT * FROM categories");
  
        if (!$query) {
            printf("Error: %s\n", mysqli_error($connect));
            // exit();
        }
  
        while ($q = mysqli_fetch_array($query)) {
  
          if($q['id']&lt;4){ ?&gt;
  
  etc...
  </code></pre>
  
  <p>Line 34 is this one:</p>
  
  <pre><code>  while ($q = mysqli_fetch_array($query)) {
  </code></pre>
  
  <p>It is the first time I do this and I am new to php and mysql so I don't have much experience. Can someone help me find the problem here. How can I debug this?</p>
  
  <p>Thank you</p>