Errors are a part of the technical lifestyle. Whether you are a casual iPhone user who barely knows how to use a computer, or a life-long programmer, errors are everywhere. Over time errors have already improved a lot, and will continue to improve, but will never go away. A decade ago, you could barely browse a few web pages without seeing dozens of errors. Today many problems have been fixed, so overall the computer experience is more pleasant, but new problems have popped up and using technology can still be frustrating.
Do you ever see this error when trying to open up CSV files in Microsoft Excel?
- “The file you are trying to open, ‘filename.csv’, is in a different format than specified by the file extension. Verify that the file is not corrupted and is from a trusted source before opening the file. Do you want to open the file now?”
And upon clicking “Yes” you receive another error message:
- Excel has detected that ‘test.csv’ is a SYLK file, but cannot load it. Either the file has errors or it is not a SYLK file. Click OK to try to open the file in a different format.
PHP exec() command is heavily used, but sometimes when using mysqldump and other commands the results can be confusing and difficult to debug.
Namely, when tables are crashed, exec()’s $retVal might end up as either 2 or 3, and the table may or may not show as Crashed when doing a “SHOW TABLE STATUS”. Try to do a mysqldump, and look at the very end of the file to check for an error. Alternatively, just attempt to REPAIR TABLE on the table after the last table it successfully backed up.
It is best to always treat any value in $retVal as an error.
PHP error reporting can be simple or difficult depending upon your application. Many sites and applications change the settings, either via the php.ini file, an .htaccess file, or directly in the PHP code. In fact, setting the values directly in the PHP code of your application is probably the most common method.
So which settings are you actually supposed to change? Try these for starters:
The following example contains the syntax:
ini_set('error_reporting', E_ALL & ~E_NOTICE);
The power of PHP often goes without question, however once in a while we remember a little something from Perl that we just wish was as easy in PHP. The truth is, so much is easier with PHP than with Perl that PHP is just awesome, but hey – it’s a programming language – it’s going to have shortcomings. The most common reason we are asked this is for crons – scheduled programs, batches, and such. Often a programmer will want to redirect the output to a certain file, or to /dev/null. In Perl, you are able to do this easy-as-cheese:
open (STDOUT, ">/path/to/file") or die "Can't redirect STDOUT: $!";
open (STDERR, ">>/path/to/file") or die "Can't redirect STDERR: $!";
Please take note: PERL redirects a filehandle in one line!
However, PHP is a bit of a different story: (more…)