title: Changing from mysql to mysqli code error
body: <p>I'm changing over a lot of files from mysql to mysqli.  I'm using this to do it: <a href="https://wikis.oracle.com/display/mysql/Converting+to+MySQLi" rel="nofollow">https://wikis.oracle.com/display/mysql/Converting+to+MySQLi</a></p>
  
  <p>My connect file (I've taken out what I think is unnecessary code such as error handling for simplicity) creates errors that I'm not sure how to fix.
  Orignial code:</p>
  
  <pre><code>$conn=mysql_connect ("$localhost", "$dbusername", "$dbpass");
  
  mysql_select_db("$db", $conn);
  </code></pre>
  
  <p>New code:</p>
  
  <pre><code>$conn=($GLOBALS["___mysqli_ston"] = mysqli_connect("$localhost",  "$dbusername",  "$dbpass")); 
  
  ((bool)mysqli_query( $conn, "USE $db"));
  </code></pre>
  
  <p>The above code is just my connect to database file which is used in every file via</p>
  
  <pre><code>include_once("includes/connnect.php");
  </code></pre>
  
  <p>The previous code which connects to the database and table must work with the below code because I've got many queries like the below and it's easier to change the connect.php file than many files: </p>
  
  <pre><code>$con1 = mysqli_query($GLOBALS["___mysqli_ston"], "SELECT * FROM table1 WHERE id='$id'"); 
  </code></pre>
  
  <p>Edit - updated to include a semi colon that I missed while copying and pasting.</p>
  
  <p>Edit 2 - Including error/warning messages from conversion tool</p>
  
  <pre><code>14  [Line 14] Please check your code for parse errors, we failed to parse " ". Conversion will be incomplete!".
  14  [Line 14] Cannot analyze server parameter to extract host, socket and port! Conversion cannot be performed automatically. You must manually check the result of the conversion.
  16  [Line 16] mysql_select_db(string database_name [...]) is emulated using mysqli_query() and USE database_name. This is a possible SQL injection security bug as no tests are performed what value database_name has. Check your script!
  </code></pre>
  
  <p>Where line 14 is </p>
  
  <pre><code>$conn=mysql_connect ("$localhost", "$dbusername", "$dbpass"); 
  </code></pre>
  
  <p>and line 16 is </p>
  
  <pre><code>mysql_select_db("$db", $conn);
  </code></pre>
  
  <p><strong>EDIT - Working answer</strong> below.  Conversion tool worked perfectly for all my other files.  Just had to change the way it connected to the database in my connect file</p>
  
  <pre><code>$conn=($GLOBALS["___mysqli_ston"] = mysqli_connect("$localhost",  "$dbusername",  "$dbpass", "$db", "3306")) or die ('Cannot connect to the database because: ' . ((is_object($GLOBALS["___mysqli_ston"])) ? mysqli_error($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_error()) ? $___mysqli_res : false)));
  </code></pre>
  
  <p>3306 is the port.  To find the port, use the below:</p>
  
  <pre><code>$port = ini_get("mysql.default_port");
  echo "the port ". $port;
  </code></pre>