title: PHP mysql_query parameter order
body: <p>I'm a bit of a noob but I am having trouble finding the answer to this question. I have two pieces of code and both work but I'm not sure why. </p>
  
  <pre><code>// Connect to the database 
  $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); 
  // Retrieve the score data from MySQL
  $query = "SELECT * FROM table";
  $result = mysqli_query($dbc,$query);            
  mysqli_close($dbc); // close db
  </code></pre>
  
  <p>In the instance above the connection is the first mysql_query parameter and then the sql query. This came from a book and isn't how the PHP manual defines it as far as I can see. </p>
  
  <p>In the next example the sql is entered first, then the connection and I have to specifically use mysql_select_db. Why do they both work? </p>
  
  <pre><code>//db connection
  $dbc = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
  $db_selected = mysql_select_db("database",$dbc); // select the db
  $sql = "SELECT * from table"; // sql query 
  $result = mysql_query($sql, $dbc); // make query on db
  mysql_close($dbc);  //close the connection after data is acquired
  </code></pre>
  
  <p>Thanks in advance for any illumination you can supply.</p>