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
  • if you run that command from the command line, does it work? Commented Oct 11, 2010 at 12:14

2 Answers 2

2

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

Sign up to request clarification or add additional context in comments.

1 Comment

which is a command not recognized on windows systems. There another one to know the absolute path?
1

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.

2 Comments

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.