I’m looking at wp-db.php and see:
1384 if ( $this->dbh->connect_errno ) {
1385 $this->dbh = null;
This is in the class function db_connect()
, which is called by the wpdb
constructor. In the latest error you describe:
Warning: mysql_error() expects parameter 1 to be resource, boolean given
we can see that mysql_error()
is not receiving the appropriate argument. This argument comes into play here:
1211 public function print_error( $str="" ) {
1212 global $EZSQL_ERROR;
1213
1214 if ( !$str ) {
1215 if ( $this->use_mysqli ) {
1216 $str = mysqli_error( $this->dbh );
1217 } else {
1218 $str = mysql_error( $this->dbh );
1219 }
1220 }
Note lines 1216 and 1218 (it differs based on whether you use mysqli extension). The argument it is passing in is your MySQL connection resource, which as seen on 1384-1385 is not defined correctly if there is a MySQL connection issue. This will make it difficult to trace the error at the point you’re doing so from, but at least now you know it’s an issue with the connection.
As @s_ha_dum indicated, you should verify your connection information to ensure that you’re able to connect. If you have WP_DEBUG
set to false
, the mysql_connect()
(lines 1409, 1411) and mysqli_real_connect()
(lines 1379, 1381) are run with the @
prefix that suppresses errors. Enable WP_DEBUG
and you should receive error text for these lines, if that is indeed where the problem lies.