Page 1 of 1

backup MySQL database from php script

Posted: Tue May 20, 2008 7:27 am
by Den
Hello,
Can any one help me with this problem?
I am trying to backup my MySQL database from php script using mysqldump. The script is:

<?php
$host = "hostname";
$database = "databasename";
$user = "username";
$pass = "password";

$dbh = mysql_connect($host, $user, $pass) or die ("Can't connect to MySQL");
mysql_select_db($database) or die ("Can't connect to db");

$bckp_file = $database.date("Y-m-d-H-i-s").".sql";
$command = "c/wamp/mysql/bin/mysqldump --add-drop-table --add-drop-database -u $user -p $pass $database > $bckp_file";

system ($command);

?>

In result I am getting only empty .sql files, without any content
when I run command "mysqldump --add-drop-table --add-drop-database -u $user -p $database > $bckp_file" from cmd its ok, i have the normal dump.
Can any tell me what's wrong with my php script?

Re: backup MySQL database from php script

Posted: Wed May 21, 2008 6:43 am
by slightlymore
try putting a colon after c, so it reads: "c:/wamp/mysql/......"