0

when i hit index page instead of error messages I'm just getting a blank page. Is there any way to show PHP error messages instead? It's very hard to debug when I get no feedback. My environment is linux. PHP

Mohit B.
  • 11
  • 3

2 Answers2

5

there are more than one way to show errors in php scripts in linux..

first, in your index.php file, insert this codes:

error_reporting(E_ALL);
ini_set('display_errors', 1);

this enables displaying errors and warning from your browser..

or second, open php.ini file located at /etc/php5/apache2/php.ini and edit the line

display_errors = Off

to

display_errors = On

and restart apache2

sudo /etc/init.d/apache2 restart

NOTE: the first method only enables error message on the current file while the second method globally enables error messages to all php scripts..

sources: display error message, show errors and warnings

Community
  • 1
  • 1
catzilla
  • 1,901
  • 18
  • 31
  • try using the linux's terminal and just type `sudo nano /etc/php5/apache2/ini.php` or just locate it using `locate ini.php` – catzilla May 06 '15 at 09:09
  • Configuration File (php.ini) Path /usr/local/lib Loaded Configuration File /home/cc97320023/public_html/php.ini – Mohit B. May 06 '15 at 09:15
  • and i dont know where usr folder is located.. i dont see any – Mohit B. May 06 '15 at 09:15
  • then I suggest modifying that php.ini file on where you found it... usr folder is located at the bottom of the file system... try using `cd /usr` and you can access that folder – catzilla May 06 '15 at 09:17
0

You have your answer in this post

Basically you have to add this 2 lines at the beginning of the file

error_reporting(-1);
ini_set('display_errors', 'On');
Community
  • 1
  • 1
SpongePablo
  • 870
  • 10
  • 24
  • Warning: require(PHPMailer\class.phpmailer.php): failed to open stream: No such file or directory in /home/cc97320023/public_html/index.php on line 5 Fatal error: require(): Failed opening required 'PHPMailer\class.phpmailer.php' (include_path='.:/usr/local/lib/php') in /home/cc97320023/public_html/index.php on line 5 – Mohit B. May 06 '15 at 08:49
  • but i have PHPMailer folder with all files – Mohit B. May 06 '15 at 08:50
  • when i use wampserver it works all fine on local server but not online – Mohit B. May 06 '15 at 08:51
  • The reason why its not working on your online server could be the php.ini, another place where you can activate/deactivate those warnings. – SpongePablo May 06 '15 at 08:54
  • About the PHP Mailer... it says that is lookin in the folder include_path='.:/usr/local/lib/php', that is automatically included, there is where PHP Mailer should be, but as I can't see your application I don't know if it is already there. – SpongePablo May 06 '15 at 08:54
  • which setting i do have to change in .ini? – Mohit B. May 06 '15 at 08:55
  • As @catzilla told you a couple answers up, change display_errors and set it to ON and then restart apache sudo service apache2 restart – SpongePablo May 06 '15 at 08:57
  • k i will try and let you know.. thanx for helping – Mohit B. May 06 '15 at 08:58