# apply with "patch -p0 -u < wordpress-2.0.5-mysqli.patch" in the root wordpress directory --- wp-db.php.old 2006-12-29 18:20:39.744503500 -0800 +++ wp-includes/wp-db.php 2006-12-29 18:23:07.953766000 -0800 @@ -40,7 +40,7 @@ // DB Constructor - connects to the server and selects a database function wpdb($dbuser, $dbpassword, $dbname, $dbhost) { - $this->dbh = @mysql_connect($dbhost, $dbuser, $dbpassword); + $this->dbh = @mysqli_connect($dbhost, $dbuser, $dbpassword, $dbname); if (!$this->dbh) { $this->bail("

Error establishing a database connection

@@ -53,24 +53,6 @@

If you're unsure what these terms mean you should probably contact your host. If you still need help you can always visit the WordPress Support Forums.

"); } - - $this->select($dbname); - } - - // ================================================================== - // Select a DB (if another one needs to be selected) - - function select($db) { - if (!@mysql_select_db($db, $this->dbh)) { - $this->bail(" -

Can’t select database

-

We were able to connect to the database server (which means your username and password is okay) but not able to select the $db database.

- -

If you don't know how to setup a database you should contact your host. If all else fails you may find help at the WordPress Support Forums.

"); - } } // ==================================================================== @@ -79,9 +61,9 @@ function escape($string) { return addslashes( $string ); // Disable rest for now, causing problems if( !$this->dbh || version_compare( phpversion(), '4.3.0' ) == '-1' ) - return mysql_escape_string( $string ); + return mysqli_escape_string( $string ); else - return mysql_real_escape_string( $string, $this->dbh ); + return mysqli_real_escape_string( $string, $this->dbh ); } // ================================================================== @@ -89,7 +71,7 @@ function print_error($str = '') { global $EZSQL_ERROR; - if (!$str) $str = mysql_error(); + if (!$str) $str = mysqli_error(); $EZSQL_ERROR[] = array ('query' => $this->last_query, 'error_str' => $str); @@ -141,43 +123,43 @@ // Keep track of the last query for debug.. $this->last_query = $query; - // Perform the query via std mysql_query function.. + // Perform the query via std mysqli_query function.. if (SAVEQUERIES) $this->timer_start(); - $this->result = @mysql_query($query, $this->dbh); + $this->result = @mysqli_query($this->dbh, $query); ++$this->num_queries; if (SAVEQUERIES) $this->queries[] = array( $query, $this->timer_stop() ); // If there is an error then take note of it.. - if ( mysql_error() ) { + if ( mysqli_error($this->dbh) ) { $this->print_error(); return false; } if ( preg_match("/^\\s*(insert|delete|update|replace) /i",$query) ) { - $this->rows_affected = mysql_affected_rows(); + $this->rows_affected = mysqli_affected_rows($this->dbh); // Take note of the insert_id if ( preg_match("/^\\s*(insert|replace) /i",$query) ) { - $this->insert_id = mysql_insert_id($this->dbh); + $this->insert_id = mysqli_insert_id($this->dbh); } // Return number of rows affected $return_val = $this->rows_affected; } else { $i = 0; - while ($i < @mysql_num_fields($this->result)) { - $this->col_info[$i] = @mysql_fetch_field($this->result); + while ($i < @mysqli_num_fields($this->result)) { + $this->col_info[$i] = @mysqli_fetch_field($this->result); $i++; } $num_rows = 0; - while ( $row = @mysql_fetch_object($this->result) ) { + while ( $row = @mysqli_fetch_object($this->result) ) { $this->last_result[$num_rows] = $row; $num_rows++; } - @mysql_free_result($this->result); + @mysqli_free_result($this->result); // Log number of rows the query returned $this->num_rows = $num_rows; @@ -362,4 +344,4 @@ } $wpdb = new wpdb(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST); -?> \ No newline at end of file +?>