PHP is a popular option for experts associated with web development and design. This is because of the fact that PHP is available with cheap hosting plans. Unfortunately, the process of installing a PHP script may go wrong at times.
And the worst part is that it may take many hours or even days to figure out a PHP error. This is especially true of web designers who do not possess good knowledge of PHP, but have to install PHP scripts sometimes. Today, we will discuss the common problems that designers face during PHP web development. Additionally, we will offer tips that will help you to deal with these problems.
Errors Associated with the Database
In certain cases, source of PHP errors lie in database connection. Usually, when a script wants to connect with a database, it will ask you certain information, such as user name and password of the database, name of the database, and address of the server.
Solution - Crosscheck the information that you have submitted. Remember that if you submit any wrong information, chances are high that an error will occur.
A Blank Page Pops Up!
In most cases, designers first install the script locally, by utilizing Mac or MAMP. Both of them will enable you to view the error messages easily. You can take help of PHP to highlight the errors on screen or arrange them in a file for observation at a later stage.
However, if you have installed the script directly in the hosting account, you may not be able to observe the error messages. This could be because of the fact that the host may have turned off display of error messages. With displays being turned off, chances are high that a serious mistake would result in display of a blank page.
Solution - A live server allows users to locate the PHP error log. In case, you cannot find the error log, try to configure PHP to retain one at a specified location. We highlight the required steps.
- Develop a directory on the website and name it as ‘errors’.
- Make it writable.
- Incorporate the code below the .htaccess file at the bottom of the site.
- Ensure that the file cannot be downloaded from the Internet. Now run the script that contributed to the error.
Ideally, the error information should be attached with the php_error.log file. In case, this trick fails, first create the file in the errors directory and make it writable.
Errors, Warnings, and Notices
PHP classifies messages that enter the error log as notices, warnings, and errors. Each of them has varying levels of severity.
A warning, for example, conveys to you that your activities are causing problems. Notices, on the other hand, warn you that something is wrong in the script. Errors usually interfere with the activities of PHP.
Solution - If an error occurs in an open-source or purchased script, checking your installation can be a good idea. Of course, this is applicable only in situations, where the user’s version of PHP fulfills the requirement.
- If you are unable to fix the warnings, contact the technical support.
- Notices do not deserve serious attention. Still, you should ensure that you have installed latest version of the script. If you get loads of notices, chances are high that you are running a poor-quality script.
PHP Errors
In certain situations, PHP error occurs due to issues with the script. Sometimes, you may get a message such as ‘fatal error: call to undefined function’. This means that the current page cannot find a PHP function that it requires. This function can be incorporated into PHP or is part of the script. If you are installing a third-party script, following reasons can cause this error.
- While installing a new script, you may have forgotten to upload the necessary files.
- You may have failed to specify the right path in a configuration file.
To deal with the error, check whether you have committed the above-mentioned mistakes. If you still cannot solve it, get in touch with developer of the script.
Most developers find PHP errors quite confusing. However, in most cases, if you read the messages carefully, you can understand source of the problem. Remember that with time and patience, you can learn how to deal with these issues effectively.