|
Posted by J.O. Aho on 09/10/06 13:10
vesakilp@gmail.com wrote:
> I've got this problem: I'm trying to backup a table from my database to
> a .sql file. I'm running mysqldump command from php file, and the
> result file is empty. Where's the problem?
>
> Code:
> <?php
> include "settings.inc";
> include "db.php";
>
> global $dbase;
> global $duser;
> global $dpass;
>
> DBConnect();
>
> $backup = "mysqldump -h localhost -u $duser -p $dpass $dbase table_name
>> backup/table_name.sql";
> shell_exec($backup);
>
> DBClose();
> ?>
>
In theory this should work, but change your shell_exec($backup); to
$error_message=shell_exec($backup);
echo "Command used: ".$backup."<br>\nOutput from command:
".$error_message."<br>\n";
in your script, and then you see how your command line looks like and what the
command does output. By the way, as you are using the mysqldump command, you
don't need to connect to the database in the php script.
At least in the mysql command you don't have spaces between -u and the
password, the same for -p too and most likely for the -h too.
$backup = "mysqldump -hlocalhost -u$duser -p$dpass $dbase table_name >
backup/table_name.sql";
//Aho
Navigation:
[Reply to this message]
|