title: mysqli_query not recognizing database?
body: <p>I've already asked a question on this code I'm working on, just not about the same problem. Either way sorry for the repost!</p>
  
  <p>So I'm having trouble with the code, as follows:</p>
  
  <pre><code>&lt;?php
  // Create connection
  
  $host = "localhost";
  $username="tudor";
  $password="passw0rd";
  
  $con=mysqli_connect($host, $username, $password);
  if(! $con )
  {
    die('Could not connect: ' . mysqli_error());
  }
  echo 'Connected successfully&lt;br /&gt;';
  
  
  $db_1 = mysqli_select_db( $con, 'db_1' );
  if (! $db_1) {
  die('Could not select database: ' . mysqli_error());
  }
  else {
  echo "Database successfully selected&lt;br /&gt;===============================&lt;br /&gt;";
  }
  
  //===================================
  
  
  
  $a = 1;
  $b = 2234;
  
  $table = "CREATE TABLE info (id INT NOT NULL AUTO_INCREMENT, city CHAR(40), country CHAR(40))";
   if (! $table) {
  die('Could not create table ' . mysqli_error($con));
  }
  else {
  echo "Table created&lt;br /&gt;";
  }
  
  $insert = "INSERT INTO info (city, country) VALUES ($a, $b)";
   if (! $insert) {
  die('Could not insert ' . mysqli_error($con));
  }
  else {
  echo "Inserted&lt;br /&gt;";
  }
  
  $select = "SELECT * FROM info";  
  
  
  $result = mysqli_query ($con, $insert);
   if (! $result) {
  die('Result not working ' . mysqli_error($con));
  }
  else {
  echo "Result working&lt;br /&gt;";
  }
  
  echo "result: ".$result['city']. " ";
  
  
  mysqli_close($con);
  
  ?&gt;
  </code></pre>
  
  <p>This outputs (blockquote doesn't display page breaks):</p>
  
  <blockquote>
    <p>Connected successfully Database successfully selected
    =============================== Table created Inserted Result not working Table 'db_1.info' doesn't exist</p>
  </blockquote>
  
  <p>What does it mean by "Table 'db.info'" not existing? It clearly says that my info table was created...
  What I tried doing is inverting the variables in the $result query: $result = mysqli_query ($insert, $con);, because I had seen that syntax in a book. However all it gave was the following message in the output:</p>
  
  <blockquote>
    <p>Warning: mysqli_query() expects parameter 1 to be mysqli, string given
    in C:\wamp...</p>
  </blockquote>
  
  <p>Thoughts anyone? Thanks in advance!</p>
  
  <p>Edit: really appreciate the help everyone, thanks a lot!</p>