tags:

views:

166

answers:

2

i tried the solution of Ngu Soon Hui and it works. how about the mysqldump. i tried using the same solution.

$cmd = $mySQLDir1.' -h '.$mydbserver.' --user='.$username.' --password='.$password.' > "'.$file2.'"';
exec('"'.$cmd.'"',$out ,$retval);

where

$mysqlDire1 = $mySQLDir1='"C:\\Web\\WebServer\\mysql\\bin\\mysqldump.exe"';
$file2 = '"C:\\database_backup\\purchase_sales.sql"';

but this makes a file with this content.

Usage: mysqldump [OPTIONS] database [tables]
OR     mysqldump [OPTIONS] --databases [OPTIONS] DB1 [DB2 DB3...]
OR     mysqldump [OPTIONS] --all-databases [OPTIONS]
For more options, use mysqldump --help

any help will be appreciated.

A: 

First thing after you declare $cmd echo it, take that output and type it into the run prompt or a command prompt and see what the output is.

Unkwntech
+2  A: 

You're not specifying which database to back up. Try adding it one, as the prompt suggests:

$cmd = $mySQLDir1.' mydatabasename -h '.$mydbserver.' --user='.$username.' --password='.$password.' > "'.$file2.'"';

Tested and works.

Paolo Bergantino