PHP Display errors & Debug

PHP Display errors & Debug
5 (100%) 1 vote

To turn on error reporting

1. Set in php.ini

display_errors = On;
error_reporting = E_ALL;

2. In php.code

//If PHP config doesn't have error_reporting enabled, simply enable it at the top of your script:
ini_set('display_errors','On');

//error_reporting sets which PHP errors are reported
error_reporting(E_ALL);

Check error logs on apache server

Check errors in log file that is configured in etc/apache2/httpd.conf

DEBUG

Php useful debugging functions

gettype($variable) – Get variable type;

var_dump($variable) – Dumps information about a variable;

get_defined_vars() – Return an array of all defined variables;

debug_backtrace() – show backtrace

var_dump(debug_backtrace());

Tools

Xdebug

Firebug

Examples of errors

MySQL Error “Incorrect integer value “for column ‘name’ at row 1”

This error appear because mysql attempting to insert or update a row with the integer entry taking the default value 0 or NULL.

MySQL return this error because SQL_MODE is set in STRICT mode.

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

To find this setting you must go to phpmyadmin -> Information schema -> Global variables -> sort them downwards by the variable names and at pag 2 will find sql_mode.

To resolve this issue have to remove STRICT_TRANS_TABLES or set SQL_MODE to an empty string, sql_mode=””

After this change you should restart MySQL.

Leave a Reply

Your email address will not be published. Required fields are marked *