title: successful mysql connection but no database selected?
body: <p>Using mysqli for the first time and struggling with the prepared statement. 
  Is this a <em>database</em> problem, or a <em>table</em> problem?</p>
  
  <p>This is using the CodeIgniter framework with autoconfig...
  <a href="http://www.codeigniter.com/user_guide/database/connecting.html" rel="nofollow">http://www.codeigniter.com/user_guide/database/connecting.html</a></p>
  
  <ol>
  <li>I'm using a database.php auto configuration file </li>
  <li>my connection is made by <code>$con = mysqli_connect() or die('Error in Connecting: ' . mysqli_error($con));</code> and appears to be successful.</li>
  <li>my prepared statement is <code>$stmt = mysqli_prepare($con, "INSERT INTO table(documentID) VALUES (?)");</code></li>
  <li>Then when I check the prepared statement I get an error <code>1046 No database selected</code>But my code just told the database selection/connection is fine. </li>
  </ol>
  
  <p>Over view in my model below:  </p>
  
  <pre><code>$con = mysqli_connect() or die('Error in Connecting: ' . mysqli_error($con));
  
  if (!$con) {
          echo "Error: Unable to connect to MySQL." . PHP_EOL;
          echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL;
          echo "Debugging error: " . mysqli_connect_error() . PHP_EOL;
          echo "&lt;b&gt;";
          exit;
      }
      else
      {
          echo "Success: A proper connection to MySQL was made! The my_db database is great." . PHP_EOL;
          echo "Host information: " . mysqli_get_host_info($con) . PHP_EOL;
  
  //Success: A proper connection to MySQL was made! 
  
  $stmt = mysqli_prepare($con, "INSERT INTO table(documentID) VALUES (?)");
  if (!$stmt) {
          echo "Problem &lt;b&gt;";
          $error = $con-&gt;errno . ' ' . $con-&gt;error;
              echo $error; // 1046 No database selected
              exit;
          }
  </code></pre>