That's just perfect - thank you so much! A few tweaks, and it
worked
fine....
--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com
- Template Triage!
http://www.projectseven.com/go
- DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs,
Tutorials & Resources
http://www.macromedia.com/support/search/
- Macromedia (MM) Technotes
==================
"Gary White" <reply@newsgroup.please> wrote in message
news:pn4sv25nfh9ics9s2mdcfu7j0c6vbs73l3@4ax.com...
> On Sun, 18 Mar 2007 13:31:14 -0400, "Murray *ACE*"
> <forums@HAHAgreat-web-sights.com> wrote:
>
>>Yes, thanks, Gary. I'll give that a try - although I
will say that I was
>>slowly getting there. 8)
>
> Okay. I played a bit more and found a couple of small
possible issues.
> This will save it as a file on the server and in the
same directory
> where the PHP file is running:
>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
> "
http://www.w3.org/TR/html4/strict.dtd">
> <html>
> <head>
> <meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
> <title>Database Backup</title>
> </head>
> <body>
> <h1>Database Backup</h1>
> <p>Please wait ...</p>
> <?php
>
> // configure these next four lines
> $host='your host name';
> $user='your user name';
> $pass='your user password';
> $db='the database to back up';
> // done configuration
>
> $connection=mysql_connect($host,$user,$pass)
> or die(mysql_error());
> mysql_select_db($db)
> or die(mysql_error());
>
> $tbls=mysql_query("SHOW TABLES")
> or die(mysql_error());
> $outfile='dbbackup-'.date('Y-m-d-His').'.sql';
> $fp=fopen($outfile,'w')
> or die('Unable to open output file.');
> fwrite($fp,"# Database backup of $db\n# ".date('m/d/Y
H:i:s')."\n\n");
> while($tblrow=mysql_fetch_row($tbls)){
> $table=$tblrow[0];
> $query="SELECT * FROM `$table`";
> $result=mysql_query($query)
> or die(mysql_error());
> if(mysql_num_rows($result)){
> $f=mysql_num_fields($result);
> $names=array();
> $types=array();
> for($i=0;$i<$f;$i++){
> $field=mysql_fetch_field($result,$i);
> $names[]=$field->name;
> $types[]=$field->type;
> }
> $row_str='';
> $rows=array();
> while($row=mysql_fetch_row($result)){
> for($i=0;$i<$f;$i++){
> $row[$i]=mysql_real_escape_string($row[$i]);
>
if(strpos("|string|blob|date|datetime|timestamp|",$types[$i]))
> $row[$i]="'$row[$i]'";
> }
> $rows[]="(".join(",",$row).")";
> }
> $rowstr=join(",\n",$rows);
> $fields="`".join("`,`",$names)."`";
> fwrite($fp,"# Empty table $table\nDELETE FROM
`$table`;\n");
> fwrite($fp,"\n# Insert values into $table\n");
> fwrite($fp,"INSERT INTO `$table` ($fields)\nVALUES
$rowstr;\n\n");
> }
> }
> fclose($fp);
> print "<p>Done!</p>\n<p><a
href=\"$outfile\">View the File
> $outfile</a></p>\n";
> ?>
> </body>
> </html>
>
> Gary