empty mysqldump file with php
I am trying to backup a databa开发者_高级运维se using the PHP system command and mysqldump.exe. I have specified the absolute path to mysqldump.exe, followed by various options.
This is how I am currently making the call -
$path = "C:\Documents and Settings\User\Desktop\ABCD\mysqldump.exe";
$command = $path." <dump options>" > <backup filename> ";
system($command);
This is generating a sql file with absolutely no contents. I figured the problem is because of the spaces in the path name, because
$path = "C:\ABCD\mysqldump.exe";
$command = $path." <dump options>" > <backup filename> ";
system($command);
works absolutely fine.
I am unable to figure out how to make things work when the path contains spaces. I checked other threads which talked about escapeshellarg, etc but using that on the path doesn't work either.
Please help.
Are you really doing this?
$system($command);
Should instead be:
// No $ on system()
system($command);
Also, try double backslashes for Windows paths:
$path = "\"C:\\Documents and Settings\\User\\Desktop\\ABCD\\mysqldump.exe\"";
精彩评论