title: How to change mysql to mysqli?
body: <p>Based on this code below I use for regular mysql, how could I convert it to use mysqli?</p>
  
  <p><strong>Is it as simple as changing <code>mysql_query($sql);</code> to <code>mysqli_query($sql);</code>?</strong></p>
  
  <pre><code>&lt;?PHP
  
  //in my header file that is included on every page I have this
  $DB["dbName"] = "emails";
  $DB["host"] = "localhost";
  $DB["user"] = "root";
  $DB["pass"] = "";
  $link = mysql_connect($DB['host'], $DB['user'], $DB['pass']) or die("&lt;center&gt;An Internal Error has Occured. Please report following error to the webmaster.&lt;br&gt;&lt;br&gt;".mysql_error()."'&lt;/center&gt;");
  mysql_select_db($DB['dbName']);
  // end header connection part
  
  // function from a functions file that I run a mysql query through in any page.
  function executeQuery($sql) {
      $result = mysql_query($sql);
      if (mysql_error()) {
          $error = '&lt;BR&gt;&lt;center&gt;&lt;font size="+1" face="arial" color="red"&gt;An Internal Error has Occured.&lt;BR&gt; The error has been recorded for review&lt;/font&gt;&lt;/center&gt;&lt;br&gt;';
          if ($_SESSION['auto_id'] == 1) {
              $sql_formatted = highlight_string(stripslashes($sql), true);
              $error .= '&lt;b&gt;The MySQL Syntax Used&lt;/b&gt;&lt;br&gt;' . $sql_formatted . '&lt;br&gt;&lt;br&gt;&lt;b&gt;The MySQL Error Returned&lt;/b&gt;&lt;br&gt;' . mysql_error();
          }
          die($error);
      }
      return $result;
  }
  
  // example query ran on anypage of the site using executeQuery function
  $sql='SELECT auto_id FROM friend_reg_user WHERE auto_id=' .$info['auto_id'];
  $result_member=executequery($sql);
  if($line_member=mysql_fetch_array($result_member)){
      extract($line_member);
  } else {
      header("location: index.php");
      exit;
  }
  ?&gt;
  </code></pre>