I am trying to create an admin panel for a site and in particular one of the features is similar to the backup/restore option in phpBB if anyone has used it. Anyway I have got this code snippet with the appropriate SQL INSERT syntax:
while ($myrow = mysql_fetch_row($result)) {
printf("INSERT INTO articles (Title,Author,Date,Blurb,Location) VALUES (%s,%s,%s,%s,%s);\n\n",
$myrow[1], $myrow[2], $myrow[3], $myrow[4], $myrow[5]);
this is what I have been using to test the information that is printed out. What I would like to know is how can I put all of the text into a variable so that I can then it write to a file. Does the code need to be altered to make it usble and viable to be put into a file?
This is what gets printed out so far:
INSERT INTO articles (Title,Author,Date,Blurb,Location) VALUES (Building Work Continues,Tom Werner,11-01-2003,Blurb,hg774);
INSERT INTO articles (Title,Author,Date,Blurb,Location) VALUES (New Term Starts,Tom Werner,08-01-2003,BLurb,eib8636);
Which is fine to be used to restore a DB at a later date because the table structure will always be the same!
Before someone says it:
- The webhost does not have shell access
- I don't want to use PHPMyAdmin because I need to make this thing as idiot proof as possible
Any suggestions?