Reputation: 31
I have this code :
function export()
{
$exp = system("mysqldump -uguku -pjustbe repadmin > back-up.sql");
if($exp) {echo 'ok';}
else { echo 'err';}
}
But it doesn't work, all it does, is to create the "back-up.sql" file, but it's blank. And I get the "err" message.
Upvotes: 0
Views: 1638
Reputation: 1169
Here you have a command that's not running properly. Best thing to do is to capture stderr (where error messages go) and see what the output is. Another thing to note is that environment variables will be different - such as the PATH (refered to by @Joshua_Martell above).
Use this command to capture stderr and see what error messages are being produced:
/usr/bin/mysqldump -uguku -pjustbe repadmin > back-up.sql 2> mysqldump.err
This also uses a full path to mysqldump
(use the right path). You also probably should add a path to back-up.sql
and, in this case, to mysqldump.err
- don't assume that PHP will run in the directory you want as it could change.
Upvotes: 1
Reputation: 7212
Try using the full path to mysqldump...
$exp = system("/full/path/mysqldump -uroot -p repadmin > back-up.sql");
which mysqldump
will tell you what the path should be.
Upvotes: 1