I'm trying to create a PHP script that will use mysqldump to backup my databases. I have the following code:
$strCommand = "mysqldump --host=$strHostName --user=$strUserName --password=$strPassword $strDBName | gzip > $strBackupFile";
$strOutput = exec(escapeshellcmd($strCommand) . " 2>&1",$arrOutput,$intReturnValue);
if($intReturnValue != 0){
etc...
However, I get an error that says "mysqldump: Couldn't find table: "|"". I have to assume it's because of the escaping (\), but if I run it without the escapeshellcmd(), if I have an error, the error is written directly to the screen, not stored in $arrOutput or $intReturnValue. If I use escapeshellcmd(), $intReturnValue is populated as is my output array $arrOutput.
What gives?? Hopefully I have supplied enough information.
Thanks!!