Page 1 of 1

mysqli_error upon moving site

Posted: Mon Nov 14, 2016 4:43 pm
by maritimer
I just moved my site to another server and I now get the following error (please note that I know almost NOTHING about php):

Code: Select all

Warning: mysqli_error() expects exactly 1 parameter, 0 given in /home/site/site.com/wp-content/themes/mytheme/tpl-myaccount.php on line 249
Line 249 looks like this:

Code: Select all

$result = mysqli_query($SQL, $wpdb->dbh) or die(mysqli_error().' on line: '.__LINE__);	
At first I thought it was due to the fact that the file was using the now deprecated, mysql, so I changed it to mysqli and got the same result.

Thank you in advance.

Re: mysqli_error upon moving site

Posted: Mon Nov 14, 2016 4:56 pm
by Christopher
I like how mysqli_error() not having a parameter also showed that the parameters for mysqli_query() are backwards (which is the error you would have gotten if mysqli_error() had the correct parameter). It should be:

Code: Select all

$result = mysqli_query($wpdb->dbh, $SQL) or die(mysqli_error($wpdb->dbh).' on line: '.__LINE__);	

Re: mysqli_error upon moving site

Posted: Mon Nov 14, 2016 11:15 pm
by requinix
That line of code would never have worked at all in its current form - old server or new server. Did you (or someone) recently try to update the code from mysql to mysqli? It looks whoever did got it wrong. You should check all the other code on your site that deals with the database to make sure it's correct.