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.