How's it going?
I'm trying to use the following function to return a string with a dumped database in it.
I get an error with this function when executing the shell command ('system' function call):
'Warning: Unable to fork [mysqldump -u -p database_name > database_backup.sql] '
...and I was careful to make sure I put in my real database name.
Also, I'm running locally (i.e. on windows) without a password which is why this is set to "".
Does anyone know what I'm doing wrong please?
function mysql_dump_data($database_name = "my_database_name")
{
$user_name = "localhost";
$password = "";
$sql_dump = "mysqldump -u$user_name -p$password $database_name > database_backup.sql";
$sql_dump_result = system($sql_dump);
echo "<br>\n sql_dump_result is " . $sql_dump_result;
return $sql_dump;
}
Many thanks if you can assist,
Regards,
Jason