i have to backup my database via php codes but i always ended up with an empty file?

include "connection.php";
$command = 'mysqldump -u root -p ***** –all-databases > dump.sql';
exec($command) or die(mysql_error());


any help would be great

Recommended Answers

All 6 Replies

I don't think or die(mysql_error() works here because you access the mysql not though php but though the shell.
to get te result back from the shell

exec('command', $result);

that code help me in showing the errors. but the file is 0kb that mean's it is empty. i want to backup all my database on my system instead of going over the cpanel again and again every day

and what are the error that you are getting?

i have no errors. the code works but it cannot save the database into an .sql file

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.