Thanks all for the help!

exec() seems the best option.


Miguel Guirao wrote:

You could use exec() within PHP!

-----Original Message-----
From: Adrian Bruce [mailto:[EMAIL PROTECTED]
Sent: Jueves, 29 de Junio de 2006 06:31 a.m.
To: Jeffrey
Subject: Re: [PHP-DB] mysqldump via php

mysqldump is a .exe, and therefore it will not work within mysql_query();

You may be able to use  mysqldump from PHP using the system function

check out


Jeffrey wrote:

I would like to do a backup of an entire MySQL database via php. My thought was to use mysqldump, write the data to a file and save the file. However...

   $query="mysqldump $dbase";
   $result=mysql_query($query) or die(mysql_error());

...immediately results in an "error in your SQL syntax near mysqldump [database name]".

The reason I want to do a MySQL back up via php is that I have a web application in which the user can archive a project, which involves moving a lot data from one set of tables to another set of tables. The user can also delete a project, which removes lots of data from the DB altogether. Although there are lots of "Are you sure you really want to do this?" messages the user must click upon, I am sure I will eventually get a user telling me she accidentally archived/deleted stuff and can I help.

So, my thought was to do a incorporate a mysqldump in the archiving/delete page. That way there would be a snapshot of the pre-action db, making it easy to put things right.

Can you help with my query - or by suggesting an alternative solution?



PHP Database Mailing List (
To unsubscribe, visit:

Reply via email to