Troubleshooting & Common Errors

A Guide to Troubleshooting PHP and Other Coding Errors

By the Domain India teamPublished 6 min read
Knowledge base article
Contents (6 sections)

When a PHP site breaks, the fastest route to a fix is the same every time: pin down exactly what fails and when, read the error log, then change one thing and test again. This page gives you that routine for sites on shared hosting, whether the site is yours or you look after it for a client, and points to the detailed guides for each step.

Key takeaways

Reproduce the problem and note the time, then read the PHP error_log in the failing script's folder and, in cPanel, Metrics › Errors. Most errors come from a recent change: a plugin or theme update, a PHP version switch, an .htaccess edit, or a memory limit. Keep display_errors off on a live site. On our servers, php_value lines in .htaccess cause a 500 error, so set PHP options in .user.ini or MultiPHP INI Editor instead.

Detailed guides

For a 500 error, start with Troubleshooting 500 Internal Server Error. To see PHP messages safely, read how to enable display_errors. For where every log lives, see reviewing error logs in cPanel and DirectAdmin.

1. Pin down the problem

Before touching code, write down:

  • The exact page and action that fails, such as "the checkout button on /cart".
  • The exact message, or a screenshot: a blank page, a 500, a 503, or a PHP warning.
  • The time it last failed, so you can match it to a log line.
  • What changed recently: a plugin, theme or core update, a PHP version change, a new .htaccess rule, a migration.

If you look after the site for someone else, ask them for these four things first.

2. Read the error log

On a live site, errors are logged rather than shown. On our cPanel and DirectAdmin servers, PHP logging is on by default.

WhereWhat you find
error_log in the failing script's folderPHP errors from that folder
logs/yourdomain_com.php.error.log in your home folder (cPanel)PHP errors for domains running PHP-FPM
cPanel: Metrics › ErrorsRecent web server errors
wp-content/debug.log (WordPress, once enabled)WordPress and plugin errors

Our cPanel servers cache pages in front of the web server, so reload the failing page with a unique query string such as ?t=debug1 to make sure your request really runs PHP and writes a fresh log line. The log gives you a file and a line number; open that file first.

3. Match the error to its usual cause

Message or symptomUsual causeWhere to go next
500 right after an .htaccess editA php_value or php_flag line, or a disallowed Options value500 error guide
Parse error or syntax errorA missing ;, bracket or quote in the named fileFix the line, or restore the previous file
Call to undefined functionA missing PHP extension, a function removed in newer PHP, or a disabled functionPHP disabled functions
Allowed memory size exhaustedThe script needs more memory, or loopsPHP memory errors
Errors after a PHP version changeOld code or plugins not compatible with the new versionChange your PHP version
503 or 508 that comes and goesThe account's resource limitsResource Limit Is Reached

4. Check PHP version and settings

  • Version: choose it per domain in cPanel's MultiPHP Manager or in DirectAdmin. Match it to what your CMS and plugins support.
  • Settings: raise memory_limit, max_execution_time or upload_max_filesize with a .user.ini file in the site's folder, or cPanel's MultiPHP INI Editor. You can't edit the server's own php.ini on shared hosting, and changes to .user.ini can take up to 5 minutes to apply.
  • Disabled functions: functions such as exec, shell_exec, proc_open and popen are disabled on our shared servers, so code that needs them has to be changed or moved to a VPS.

5. Debug the code

  • Add ini_set('display_errors', '1'); and error_reporting(E_ALL); at the top of one script on a test copy, read the message, then remove the lines.
  • Use error_log(print_r($value, true)); to log a variable instead of printing it.
  • For WordPress, set WP_DEBUG and WP_DEBUG_LOG to true and WP_DEBUG_DISPLAY to false in wp-config.php, then switch it off when done.
  • For step-through debugging with Xdebug, work on a copy of the site on your own computer or a VPS, not on the live shared account.
  • Temporarily switch off the most recently updated plugin or theme; if the error stops, you have found it.

6. Test and follow up

Change one thing at a time and retest with a fresh ?t= value. When it works, note the cause and the fix, and check the log again a day later.

Where do I find PHP errors on Domain India hosting?

Look for an error_log file in the same folder as the failing script. On cPanel, also check logs/yourdomain_com.php.error.log in your home folder and Metrics, Errors in cPanel. PHP error logging is on by default on our cPanel and DirectAdmin servers.

Can I turn on display_errors with .htaccess?

No. Our shared servers don't run PHP as an Apache module, so a php_value or php_flag line in .htaccess causes a 500 error. Use a .user.ini file or ini_set() in one script on a test copy.

Can I edit php.ini on shared hosting?

Not the server's php.ini. You can change settings for your own site with a .user.ini file, or on cPanel with the MultiPHP INI Editor. Changes to .user.ini can take up to 5 minutes to apply.

Why does my site show an old page after I fixed the error?

Our cPanel servers cache pages in front of the web server. Add a unique query string such as ?t=123 to the address to load a fresh copy.

Can support fix my code?

Support can read your account's server logs with you and tell you what the error points to. Changing your site's code is your developer's job.

Ready to find the cause? Start with the 500 error guide, or open a ticket with the page address and the time it failed.

Stuck on an error?

Send us the page address, the time of the error and what changed last, and we will read your account's logs with you.

Open a support ticket

Ready when you are

Get cPanel hosting from ₹125/mo + GST

See plans

Was this article helpful?

Your answer helps us decide what to improve next.

Still need help? Open a support ticket and our team will reply.

Prefer an app? Add this site to your home screen.Get the app
How to Troubleshoot PHP Errors on Shared Hosting