views:

35

answers:

2

I've the code shown below but nothing happens after execution

system('mysqldump -u USER -pPASS DB > /tmp/bckp.sql');

What is wrong with this code?

Sultan

+1  A: 

there could be thausands of things going wrong:

  • do you get any error messages?
  • have you tried to echo system(... - and whats the result?
  • what is the return value?
  • have you tried to use exec or passthru instead?
  • are you sure your db-name, user and password are spelled correctly?
  • what happens if you fire that command on the terminal on your own?

some more information would be realy useful to help you.

oezi
If execute this command directly from my console it works well, but via php script it doesn't
sultan
Seems there were restrictions on executing of a system commands, so for now it works
sultan
+2  A: 

You most likely need to specify the full path to mysqldump as it probably isn't in your PATH environment variable for the user PHP is running as. Go to command line on the server and run

which mysqldump 

It will spit out the full path. Then replace mysqldump in your system() command with that full path

Mark