Archive for August, 2011

PHP exec() and mysqldump – Error Code 3 and other errors

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.