Welcome to WebmasterWorld Guest from 54.147.217.76

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

PHP MySql dump not possible

   
10:26 pm on Aug 25, 2006 (gmt 0)

10+ Year Member



Have been struggling to wite a script to do a dump with php - It writes a dump file, but it is always empty (0kb)?

$link=mysql_connect ($host, $user) or die ;
mysql_select_db ($database) ;
$fish = (" mysqldump $database > $pathdump\\$filename ");
exec($fish);

Is it possible?

10:43 pm on Aug 25, 2006 (gmt 0)

10+ Year Member



since you are calling mysqldump from the shell, you do not need to create a PHP connection to the database. The mysqldump command is probably not connecting to the database and is outputting nothing. You should try some thing like:
$command ="mysqldump --host=$host --user=$user_name --password=$password $database > $pathdump/$filename";
exec($command);
11:10 pm on Aug 25, 2006 (gmt 0)

10+ Year Member



Hey Jezra -

That code worked first shot - thank you very much.

:-)