Imad Posted March 17, 2008 Share Posted March 17, 2008 Hi guys, I'm trying to create this database backup script but it isn't working. Here's the code: // Database backup system $settime = date(_mdys); $namer = "$dbname$settime.txt"; $backupdoc = "inc/backup/$namer"; $query = "SELECT * INTO OUTFILE '$backupdoc' FROM comments"; if (mysql_query($query)) { echo "<br />The Backup created successfully!"; } else { echo "<br />The Backup couldn't be created!"; } Any help would be appreciated. Quote Link to comment Share on other sites More sharing options...
Imad Posted March 17, 2008 Author Share Posted March 17, 2008 Everything seems fine, but it still won't work. I gave this a try: $settime = date(_mdys); $namer = "$dbname$settime.txt"; $backupdoc = fopen("inc/backup/$namer","w"); $query = "SELECT * INTO OUTFILE '$backupdoc' FROM users"; if (mysql_query($query)) { echo "<br />The Backup created successfully!"; } else { echo "<br />The Backup couldn't be created!"; } But it just creates a blank file as I expected. Any Ideas?? Regards. Quote Link to comment Share on other sites More sharing options...
corbin Posted March 18, 2008 Share Posted March 18, 2008 Chances are, mysql interprets relative paths as relative to the MySQL binary.... Try giving it a full path (eg: /inc/backup/blahblah) Quote Link to comment Share on other sites More sharing options...
Imad Posted March 18, 2008 Author Share Posted March 18, 2008 Thanks for your help. Unfortunately it didn't work. I can't possibly find anything wrong with my script, but I might be missing something. Any other ideas? Thanks. Quote Link to comment Share on other sites More sharing options...
eddierosenthal Posted March 18, 2008 Share Posted March 18, 2008 this line: $backupdoc = fopen("inc/backup/$namer","w"); fopen returns a file handler, not a string. and so when you passed what you thought was a filename you passed to the mysql query a pointer ( internal). try passing the full name of the output file to the query. hth Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.