Knowledge Base
MilesWeb / Web Hosting FAQ

Discover the PHP Error Messages That Web Designers Should Know About

Approx. read time : 7 min

When you quickly search the Internet, you will get the PHP definition as below:

Open source general-purpose scripting language that is especially suited for web development and can be embedded in HTML

PHP stands for ‘Hypertext Pre-processor’. Note that only servers with PHP installed can read and interpret PHP scripts. For giving an example of the popularity of PHP, it is now compulsorily given with majority of web hosting plans such as shared, dedicated, VPS or cloud hosting. When it comes to WordPress which is one of the most popular open source content platforms in the world, PHP is the most used script.

You can track any errors in the PHP script die to an inbuilt system. Note that some PHP installations on the server will “switch off” the error display element. This helps to secure the integrity of the server. But there is an alternate option of tracking errors through an error log file. With this log you can see the kind of errors occurring and how frequently.

You might find PHP scripts fairly technical but after you start breaking them down, you can easily read the database related errors and PHP warning vocabulary. Now, let’s take a look at some of the common PHP error messages that web designers should be aware of while creating dynamic tools for their websites.

How to Locate the Error Log?

PHP errors can be found via an error log that can be opened up simply from the web server. Here, you will get a detailed list of the error types that have occurred and it is the basic area for correcting the PHP code. You will find the file’s wording fairly straightforward and easily accessible, often in a stand-alone directory. It is good to password protect the error log/directory to avoid hackers from being able to download it directly from the website. In case they get a chance to enter and know the errors, they might also get a way for backdoor entry.

In case, there are any issues to find the PHP error log, it is recommended to contact your hosting provider for more information.

Blank Screen

Occasionally, you might come across the blank screen while running the PHP code along with HTML. You will find that you won’t easily succeed in the attempt to view the source code as the error would result in the markup being cut off. The blank screen is an indication that there is an error after some HTML code relating to the format of PHP code. It might be similar to missing a symbol from the PHP script but when you check the error log, you will learn where the error has occurred and would be able to find the solution for it.

The Most Important Is The First Error

Once you know about a PHP script error, you might get introduced to several errors on the PHP error log. This will increase your concern but you will many times find that the first error only leads to other hundreds of errors.

Fortunately, in several cases, while rectifying the first error the rest will disappear automatically. Checking the time when the errors were logged is the best way to find the specific errors that have a knock-on effect. You will find the groups of errors with the same time stamp due to the speed of your server operation. So, pick the first error in this batch, repair it and if you are lucky the rest will disappear too.

Database Related Errors

Majority of PHP errors involve database connection issues that might include the database password username, server address and the database name. If there is any issue with any of these four elements then there won’t be any connection and you will get an error displayed. Below are some of the most common errors that you will see:

• The user has entered localhost rather than an IP address or URL for the database server
• An incorrect user name has been entered
• An incorrect database name has been entered

Database Permission Problems

You might face a situation where the server address, username, password and database name are correct but still you get the connection issues. There are some PHP scripts that need permission to create additional tables depending upon the information from the database. If the user isn’t setup with the needed permission, it will lead to an error and the PHP script won’t work correctly. One of the easiest ways to solve these types of database related errors is to trick the relevant box and add the privileges to the user.

PHP Error Messages

You will find database issues relatively easy to resolve as compared to PHP errors that look a bit trickier. But after understanding what the errors actually mean, the game becomes very easy.

1. Fatal Error: Call to Undefined Function

Shortly speaking, the cause of this error is the PHP function detailed in the PHP script can’t be found. It commonly occurs while installing a third-party script if. Below are some of the reasons for this error to occur:

• All the files related to a new script aren’t been uploaded.
• While upgrading a PHP script, one of the files isn’t been replaced.
• There is a missing PHP include or incorrect path in a configuration file.
• You have attempted to use a PHP function not available on your server.

This type of error occurs due to a missing file, or missing upgraded file, which is easy to resolve. You will face several situations where commands are missing from your PHP installation. The reason might be that you are still using an older version and you will need the assistance of your hosting provider to resolve.

2. Fatal Error: Cannot Redeclare

You will get this type of error when you have included a file twice within your script text. To resolve this error you will need to go back over the code to check included files and ensure there is no duplication.

3. Fatal Error: Allowed Memory Size Exhausted

This is a fairly common error that occurs while trying to upload/process an image which may require high memory capacity to run. Your host provider allocate limited amount of script memory capacity and if additional capacity is required, they will need to make the adjustments.

4. Permission Errors

You will come across various permissions relating to individual directory permissions. You can adjust the configuration easily. But make sure you are aware of the power of allowing write-to file options.

5. PHP Warning: Include

You will find this error message interesting because it is not an error as such, it is a warning. The script will accurately keep on moving on to the next command and will continue trying to load the page though it can’t find the include file. At this point you are likely to get formatting errors and non-fully functioning pages.

How to Resolve PHP Error Step-By-Step?

In this article it is impossible to cover all of the potential errors you may encounter with PHP script. But let’s take a look at PHP warnings or database related errors that are easy to fix. The process is fairly simple:-

• Check the PHP error log.
• Identify the first error (using the time log).
• Correct first error.
• Recheck the PHP error log.
• Rectify the next error.
• Repeat.

Many of the PHP scripts are related to WordPress and the thousands upon thousands of WordPress plug-ins. It is possible that you may also see an array of PHP errors when you upgrade the PHP version on your server. You will find that some of the older plug-ins won’t always be compatible with newer versions of PHP. This can lead to a question that do you want to lose the added functionality of the new PHP version, and remove incompatible plug-ins, or do you want to stick with the older PHP version and favored plug-ins?

Overall, PHP is a major language for the programming world. This is because it helps website designers to create dynamic websites with amazing levels of interaction. As compared with the other best programming languages, PHP is simple to use and the majority of errors that occur with it are fairly easy to resolve.

Also Read:

PHP Fatal error: Out of memory (allocated 20185088)

PHP Installation Appears To Be Missing the MySQL Extension

Need help? We’re always here for you.