mysqli_error upon moving site

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
maritimer
Forum Newbie
Posts: 1
Joined: Mon Nov 14, 2016 4:36 pm

mysqli_error upon moving site

Post 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.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: mysqli_error upon moving site

Post 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__);	
(#10850)
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: mysqli_error upon moving site

Post 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.
Post Reply