homepage Welcome to WebmasterWorld Guest from 50.17.162.174
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Accredited PayPal World Seller

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
MySqldump creates empty file?
Trying to backup database
Rhys




msg:3055019
 9:59 pm on Aug 21, 2006 (gmt 0)

I am Trying to create a one click backup database script so non-geek office staff can do this, but so far I can only output empty files

$db_user = "root";
$db_password = "";
$db_database = "or";
$db_server = "localhost";
$backup_path = "C:\\xampp\\htdocs\\openreal\\admin\\backup\\";
$path_to_mysqldump = "C:\\xampp\\mysql\\bin\\";
$filename = "backup".date("YmdHis").".sql";

shell_exec ("mysqldump $db_database > $path_to_mysqldump.$filename --user=$db_user --password=$db_password");

I have tried various forms of this syntax with no content output?

 

jatar_k




msg:3055989
 5:21 pm on Aug 22, 2006 (gmt 0)

have you tried you dump command via command line to see if it works? Start with that

echo your full line to try it

$dumpcmd = 'mysqldump $db_database > $path_to_mysqldump.$filename --user=$db_user --password=$db_password';

echo $dumpcmd;

then paste it via the command line and see what it does

Rhys




msg:3056686
 4:32 am on Aug 23, 2006 (gmt 0)

Good clue -
did some testing on the cmd window and got it all working : ie, this command writes a db dump to the file in temp -

C:\xampp\mysql\bin\mysqldump.exe --databases or --user=root --ignore-table=or.oporeal_controlpanel > C:\temp\.mychat.sql ; system

but in php it writes the file ok but it is empty (0 bytes)

This is my php version of the same command -

$dump_cmd=("$path_to_mysqldump.mysqldump.exe --databases or --user=root --ignore-table=or.oporeal_controlpanel > $backup_path.$filename ");

Rhys




msg:3056946
 10:47 am on Aug 23, 2006 (gmt 0)

OK - problem solved -

Seems the "$path_to_mysqldump" has to be in there too.

This code works fine now on my local machine :

$fish= "$path_to_mysqldump\\mysqldump.exe --u $db_user --ignore-table=$db.$config $db > $filename ";

exec($fish);

You would need --p=$passwd after User (if it was set)

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved