Couldn’t connect to database server magial_rules error

After a recent WordPress update (to 3.3), one of my blogs showed the following error:

Couldn't connect to database server. Couldn't find database magical_rules. An unexpected problem has occured with the application.

SELECT statscurl_id FROM `statscurl` WHERE statscurl_ip = '';

So how to solve this problem? Googling lead me to various websites and blogs that discussed possible solutions to this problem. This seems to be a problem specifically with Elegant Themes. Below is what worked for me.

While opening my blogs, I have always wondered why the page was trying to access "". This looked fishy to me. I tried to find out but gave up after a few minutes. I discovered that something had changed in this link "" and that was causing the database error described above.

In order to solve the above problem, edit the header.php file located under /wp-content/themes/ThemeName. You may do this from wordpress dashboard->Appearance->Editor or using your favorite text editor if you have access to the server.

Find the following line:

$url = "";

Comment it out as shown below so that the line is skipped during page display.

/* $url = ""; */

Save the file and refresh your page. The database error should now go away.

If you would like to optimize your WordPress URL structure to make it more search engine and user friendly, please read this post.

Hope this helps.

Did this post help you?
SmartHomeBeginner brings in-depth tutorials easy enough to understand even for beginners. If you are reading this, please consider buying us a coffee (or two) as a token of appreciation.


Anand is a self-learned computer enthusiast, hopeless tinkerer (if it ain't broke, fix it), a part-time blogger, and a Scientist during the day. He has been blogging since 2010 on Linux, Ubuntu, Home/Media/File Servers, Smart Home Automation, and related HOW-TOs.