TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 01-14-2008, 09:27 PM   #1 (permalink)
The Acquainted
 
Gareth's Avatar
 
Join Date: Jan 2008
Posts: 136
Thanks: 4
Gareth is on a distinguished road
Default Backing up a Database NOT via PHPMyAdmin

Hello.

I would like to be able to back up parts of my database by providing a form / link which will give the admin the choice to download the file in a sql format (like in IPB).

I have researched this a little; and been succesful in being able to backup the database into a location on the server where I define, but I'm not sure how I can change it into being download-able (obviously if it is downloaded I don't want it on the server anymore...).

This is what I have so far (I have commented it):

PHP Code:
<?php
include 'conf_global.php'// File with database settings

$tableName  'a_table'// The table which the admin has chosen to backup (Static for exemplory reasons)
$backupFile 'backup/DATE_TABLE.sql'// Where the sql is places
$query      "SELECT * INTO OUTFILE '$backupFile' FROM $tableName"// Back up table into file
$result mysql_query($query); // Query it

if ($result){
    echo 
'Database Backed Up';    // If succesful
}
else {
    echo 
'Database NOT Backed Up'// If not..
}
?>
Can someone help me please?
Much appreciated.
Gareth
Gareth is offline  
Reply With Quote
 



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 07:22 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design