WordPress is powered by a very popular set of programming code referred to as a web script along with the program language PHP which stands or Hypertext Preprocessor which is a recursive acronym, however, back in the late 1980’s, when the creator started creating the coding foundation it was originally for his personal use on his computer to make things easier to organize for heavily used programs, and was first named Personal Home Page, thus PHP. Since that time, the language has taken a life of its own and along with MySQL mostly always used together, both has become the most popular and widely used program language used and what WordPress has at its core/foundation.
From time to time, however, the website owner and visitors alike will receive an error from PHP coding stating that the database either is unable to connect or some other error statement. Most common given is the “could not connect database” or “database is offline or otherwise unavailable” Usually, when the error is given in the browser (Chrome IE etc.) it will also give like a summary of the issue along with any error within the script, if the error is due to syntax issues or misconfigurations, for instance, if PHP does actually connect by logging in to the database, however, it can’t continue processing or running the script command to display requested result of query, then the browser will be blank except for at the top of the page which will have something similar to the following: “Warning: Cannot modify header information - headers already sent by (output started at /some/file.php:12) in /some/file.php on line 23” This tells what is wrong and the database cannot continue because the header information from the page header was sent early and the last part after the parenthesis */some/file.php on line 23* this tells where the error occurred and what to correct.
Now with a *cannot connect to database* or *need MySQL in order for script to properly function…* or whatever it may say, the coder can put any type message for an error but you will know that it is a communication issue between PHP and MySQL. The first thing that needs to take place is go to the configuration file which could be named, in any number of ways, just depends on the preference of the coder, but usually it will be something like *CONFIG.PHP, CONFIGURATION.PHP, CONNECT.PHP* or similar even *SETTINGS.PHP or SETTINGS. PHP even VARS.PHP* you can check with the WordPress documentation to get the correct name and where the file is located but usually there are two (2) one inside usually the ‘includes’ folder in main directory and one in the admin directory. Check first with you host provider, they can help you with things especially if it happens to be on their side of things.
Check the php file that holds the MySQL login settings, making sure that the database, database user name and password/phrase is correct, no spaces, periods, or anything else is present. Correct any that is incorrectly entered, if all of these settings are correct, make sure that all permissions on the files/folders (referred to as (CHMOD sometimes) are properly set. Also, do not edit the files on the server, edit the file on your computer then save it as a PHP file, (HINT** when saving a file as a PHP file, you will notice there is no option to save it as PHP in the drop down box on the save as screen, so you can easily still save it as PHP or any other file type by doing the following – click “save as” (not save) then write the name u want to name the file as follows: “somename.php” make sure to place the quotation marks around the name, that forces the file type to be saved. If the MySQL cannot locate the proper file that connects the script to it then it cannot access the saved data for the website therefore the WordPress program won’t work or run until the connection can be created. Most of times this occurs because of misconfiguration or not being set with the login information needed to create a connection between WordPress and MySQL DB.
These simple steps are the beginnings of troubleshooting error codes that can, at any given time, shut down a website. Also could save time and possibly a lot of money hiring a programmer to fix a simple fix to begin with. The one thing to remember is, do not panic, take a deep breath and eliminate all the obvious first, then go to the next step. Just take time to think and be sure.