In a hole in the ground there lived a hobbit. He never went on any adventures or did anything unexpected — until thirteen bearded, pointy-eared, and boisterous dwarves show up at his doorstep and sweep him away on a long, unexpected journey to seek treasure and battle foes.
The Challenge of Programming
Like J.R.R. Tolkien’s fictional character, Bilbo Baggins, I’ve mustered the courage to step out of my cozy hobbit hole and set out an adventure to learn PHP, MySQL, and jQuery. Along the way, I have unexpectedly stumbled into fierce minions lurking in the shadows, namely, syntax errors and null variables that corrupt my customized web applications. Even the smallest error might result in anything from displaying a blank webpage to erasing important database content. At times, the source of these errors can be overwhelmingly difficult to detect as I exert myself to find a solution.
The ‘Error_Log’ is Your Ally
Fortunately, the burden of error detection can be alleviated by a handy file that the server outputs when an error is detected. The ‘error_log’ file tracks errors that are thrown on a webpage, indicating the type of error, as well as the file and line that caused it.
For example, when I attempt to store the previous month as a variable using PHP pre-defined date() and mktime() functions, the webpage ‘hobbits.php’ results in a blank page:
$previousMonth = date('m', mktime((0, 0, 0, $month-1, 1, date('Y')));
The error log indicates that I had typed an unexpected token:
[15-Nov-2012 13:43:04] PHP Parse error: syntax error, unexpected '(' in /home/username/public_html/mysite/wp-content/themes/lotr/hobbits.php on line 17
Simply by removing the extra ‘(‘ token, I was able to reverse the damage.
The error log detects a variety of errors including calls to undefined functions, invalid SQL statements, and faulty data types often caused by messy code. By using this feature, I recognize my most common errors and acquire an ability to prevent myself from repeating them. I no longer linger on tasks due to repetitive petty errors. And so my adventure in programming continues…
By: Sarah
The comments are closed.
No reviews yet