I have the following code to execute mysqldump
using exec()
. It was not working and I wanted figure out what output the command line throws. So I printed $output
and $worked
. But all I get is 1
and an empty array.
Accordong to manual: If the output argument is present, then the specified array will be filled with every line of output from the command.
But why is this throwing an empty array? I am including 2>&1
at the end of command as some post suggested, but still not working. I want to know what the terminal is outputting when this command is being executed.
And what does $worked
outputting 1
mean?
Any help will be greatly appreciated!
Script:
$command='mysqldump --opt -u ' .$db['username'] .' -p' .$db['password'] .' --databases ' .$db['database'] .' > '.$mysqlExportPath .' 2>&1';
$output=array();
exec($command,$output,$worked);
print $worked.'<br>';
print_r($output);
Outputs:
1
Array ( )