Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Programmatic backup of MySQL data?

LEGEND ,
Mar 16, 2007 Mar 16, 2007
How can I do this with PHP?

--
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
==================



TOPICS
Server side applications
2.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 16, 2007 Mar 16, 2007
Murray *ACE* wrote:
> How can I do this with PHP?

Why do you want to do it with PHP? You backup MySQL with mysqldump.
Create a batch file and run it as a scheduled task.

--
David Powers, Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 16, 2007 Mar 16, 2007
On Fri, 16 Mar 2007 11:32:31 -0400, "Murray *ACE*"
<forums@HAHAgreat-web-sights.com> wrote:

>How can I do this with PHP?

here are some links for you to peruse:

http://www.php-mysql-tutorial.com/perform-mysql-backup-php.php

http://www.developertutorials.com/tutorials/php/backup-mysql-database-php-050409/page1.html

--
Steve Fleischer
steve at flyingtigerwebdesign dot com
Hong Kong
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 17, 2007 Mar 17, 2007
On Sat, 17 Mar 2007 16:59:01 -0400, "Murray *ACE*"
<forums@HAHAgreat-web-sights.com> wrote:

>I'm not out of the woods yet. Here's my code -
>
(snip)

>It's a runaway loop. Can you please take a look and see why that might be
>happening?

What about changing the upper limit of you for statements to <= rather
than just < ?

--
Steve Fleischer
steve at flyingtigerwebdesign dot com
Hong Kong
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 17, 2007 Mar 17, 2007
Since the counters start at 0, then I think "<" is the correct usage.

What's puzzling me is that inner $x loop. The count($row['$j']) is not
working as intended, I'm sure.

--
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
==================


"Steve Fleischer" <me@invalid.com> wrote in message
news:m8mov25srjjcdnkavm10n17lkh8n5aqkmu@4ax.com...
> On Sat, 17 Mar 2007 16:59:01 -0400, "Murray *ACE*"
> <forums@HAHAgreat-web-sights.com> wrote:
>
>>I'm not out of the woods yet. Here's my code -
>>
> (snip)
>
>>It's a runaway loop. Can you please take a look and see why that might be
>>happening?
>
> What about changing the upper limit of you for statements to <= rather
> than just < ?
>
> --
> Steve Fleischer
> steve at flyingtigerwebdesign dot com
> Hong Kong


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 18, 2007 Mar 18, 2007
I can see now, after careful dissection of your second link, that this whole
approach is flawed, *and* that the base code contains errors. I'll see if I
can come up with an improvement....

--
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
==================


"Steve Fleischer" <me@invalid.com> wrote in message
news:m8mov25srjjcdnkavm10n17lkh8n5aqkmu@4ax.com...
> On Sat, 17 Mar 2007 16:59:01 -0400, "Murray *ACE*"
> <forums@HAHAgreat-web-sights.com> wrote:
>
>>I'm not out of the woods yet. Here's my code -
>>
> (snip)
>
>>It's a runaway loop. Can you please take a look and see why that might be
>>happening?
>
> What about changing the upper limit of you for statements to <= rather
> than just < ?
>
> --
> Steve Fleischer
> steve at flyingtigerwebdesign dot com
> Hong Kong


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 20, 2007 Mar 20, 2007
LATEST
On Tue, 20 Mar 2007 15:49:41 +0100, Paul Westrich <nomadaNOSPAM@gmx.net>
wrote:

>Thanks Gary for this clarification. I doubt if my database
>will ever contain 11,000 records. So there is plenty of
>space left.

You're welcome, Paul. Let me know if you run into any issues.

Gary
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 18, 2007 Mar 18, 2007
Murray *ACE* wrote:
> I can see now, after careful dissection of your second link, that this whole
> approach is flawed, *and* that the base code contains errors. I'll see if I
> can come up with an improvement....

That's the problem with a lot of online "solutions". I've no idea who
wrote the routine, but even the best programmers make mistakes. Often,
somebody posts a "tutorial" without realizing there's something wrong
with the script. Unless it's corrected, the mistake gets perpetuated,
causing grief to endless numbers of people.

--
David Powers, Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 18, 2007 Mar 18, 2007
I'm currently grieving! 8)

Don't think you've seen the last of me....

--
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
==================


"David Powers" <david@example.com> wrote in message
news:etjg1a$r6t$1@forums.macromedia.com...
> Murray *ACE* wrote:
>> I can see now, after careful dissection of your second link, that this
>> whole approach is flawed, *and* that the base code contains errors. I'll
>> see if I can come up with an improvement....
>
> That's the problem with a lot of online "solutions". I've no idea who
> wrote the routine, but even the best programmers make mistakes. Often,
> somebody posts a "tutorial" without realizing there's something wrong with
> the script. Unless it's corrected, the mistake gets perpetuated, causing
> grief to endless numbers of people.
>
> --
> David Powers, Adobe Community Expert
> Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
> Author, "PHP Solutions" (friends of ED)
> http://foundationphp.com/


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 16, 2007 Mar 16, 2007
I want my bro to be able to trigger this after he does a big update to the
database. This will happen on a non-regular basis. Seems like PHP would be
the better way to do it, no?

--
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
==================


"David Powers" <david@example.com> wrote in message
news:etegmp$miq$1@forums.macromedia.com...
> Murray *ACE* wrote:
>> How can I do this with PHP?
>
> Why do you want to do it with PHP? You backup MySQL with mysqldump. Create
> a batch file and run it as a scheduled task.
>
> --
> David Powers, Adobe Community Expert
> Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
> Author, "PHP Solutions" (friends of ED)
> http://foundationphp.com/


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 16, 2007 Mar 16, 2007
Murray *ACE* wrote:
> I want my bro to be able to trigger this after he does a big update to the
> database. This will happen on a non-regular basis. Seems like PHP would be
> the better way to do it, no?

If it's being manually triggered, it makes sense. I see that Dr
Fleischer has done the honours with some links.

--
David Powers, Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 16, 2007 Mar 16, 2007
Its pretty easy, using exec() to call mysqldump.

You can even extend the script to connect to an FTP server somewhere else
and upload the backup for safe keeping.

I wrote a tutorial on it years ago for DMX Zone.

--
Gareth
http://www.phploginsuite.co.uk/
PHP Login Suite V2 - 34 Server Behaviors to build a complete Login system.


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 16, 2007 Mar 16, 2007
The first of the methods (on the first link) looks like the one of choice
for me, but I'm getting the or die part of this code -

mysql_select_db($database_wildimages, $wildimages);

$tableName = 'tbl_images';
$backupFile = 'backup/images'.date("y-m-d").'.sql';
$query = "SELECT * INTO OUTFILE '$backupFile' FROM $tableName";


$result = mysql_query($query) or die('Oops');


What did I forget?

--
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
==================


"Steve Fleischer" <me@invalid.com> wrote in message
news:13hlv2l6u578rbefq16lso840ebi1ehtqm@4ax.com...
> On Fri, 16 Mar 2007 11:32:31 -0400, "Murray *ACE*"
> <forums@HAHAgreat-web-sights.com> wrote:
>
>>How can I do this with PHP?
>
> here are some links for you to peruse:
>
> http://www.php-mysql-tutorial.com/perform-mysql-backup-php.php
>
> http://www.developertutorials.com/tutorials/php/backup-mysql-database-php-050409/page1.html
>
> --
> Steve Fleischer
> steve at flyingtigerwebdesign dot com
> Hong Kong


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 16, 2007 Mar 16, 2007
I want it to trigger from the server, and to save the backup on the server.

I am trying the code posted earlier but it's not working for me....

--
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
==================


"gareth" <support@nospam_phploginsuite.co.uk> wrote in message
news:etej65$pt9$1@forums.macromedia.com...
> Its pretty easy, using exec() to call mysqldump.
>
> You can even extend the script to connect to an FTP server somewhere else
> and upload the backup for safe keeping.
>
> I wrote a tutorial on it years ago for DMX Zone.
>
> --
> Gareth
> http://www.phploginsuite.co.uk/
> PHP Login Suite V2 - 34 Server Behaviors to build a complete Login system.
>


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 16, 2007 Mar 16, 2007
gareth wrote:
> Its pretty easy, using exec() to call mysqldump.

I'm that a lot of hosts disable exec().

--
David Powers, Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 16, 2007 Mar 16, 2007
Murray *ACE* wrote:
> What did I forget?

A connection to MySQL?

Although or die('Oops'); is cute, or die(mysql_error()); would tell what
the problem really is.

--
David Powers, Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 16, 2007 Mar 16, 2007
I like cute. 8)

The full code block now is -

<?php require_once('../Connections/wildimages.php'); ?>
<?php

mysql_select_db($database_wildimages, $wildimages);

$tableName = 'tbl_images';
$backupFile = 'backup/images'.date("y-m-d").'.sql';
$query = "SELECT * INTO OUTFILE '$backupFile' FROM $tableName";
//echo $query;

$result = mysql_query($query) or die(mysql_error());

?>

In this case, however, cute has failed me and I can see that the error is a
permissions one. Sigh....

--
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
==================


"David Powers" <david@example.com> wrote in message
news:etel00$rsp$3@forums.macromedia.com...
> Murray *ACE* wrote:
>> What did I forget?
>
> A connection to MySQL?
>
> Although or die('Oops'); is cute, or die(mysql_error()); would tell what
> the problem really is.
>
> --
> David Powers, Adobe Community Expert
> Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
> Author, "PHP Solutions" (friends of ED)
> http://foundationphp.com/


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 16, 2007 Mar 16, 2007
David Powers wrote:
> gareth wrote:
>> Its pretty easy, using exec() to call mysqldump.
>
> I'm that a lot of hosts disable exec().

Er, fill in missing verb... I'm sure that...

--
David Powers, Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 16, 2007 Mar 16, 2007
OK - I'm still getting the error. Host tells me that the folder is wide
open. Host also wonders about one's ability to write from a SQL server to a
local file (it's windows, in case you were wondering).

Here's the error -
Access denied for user 'wildimages'@'%' (using password: YES)


--
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
==================



"Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
news:etelo4$t5t$1@forums.macromedia.com...
>I like cute. 8)
>
> The full code block now is -
>
> <?php require_once('../Connections/wildimages.php'); ?>
> <?php
>
> mysql_select_db($database_wildimages, $wildimages);
>
> $tableName = 'tbl_images';
> $backupFile = 'backup/images'.date("y-m-d").'.sql';
> $query = "SELECT * INTO OUTFILE '$backupFile' FROM $tableName";
> //echo $query;
>
> $result = mysql_query($query) or die(mysql_error());
>
> ?>
>
> In this case, however, cute has failed me and I can see that the error is
> a permissions one. Sigh....
>
> --
> 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
> ==================
>
>
> "David Powers" <david@example.com> wrote in message
> news:etel00$rsp$3@forums.macromedia.com...
>> Murray *ACE* wrote:
>>> What did I forget?
>>
>> A connection to MySQL?
>>
>> Although or die('Oops'); is cute, or die(mysql_error()); would tell what
>> the problem really is.
>>
>> --
>> David Powers, Adobe Community Expert
>> Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
>> Author, "PHP Solutions" (friends of ED)
>> http://foundationphp.com/
>
>


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 18, 2007 Mar 18, 2007
On Sun, 18 Mar 2007 09:56:18 -0400, "Murray *ACE*"
<forums@HAHAgreat-web-sights.com> wrote:

>I'm currently grieving! 8)
>
>Don't think you've seen the last of me....


Murr, you still having problems with this? This isn't thoroughly tested,
but you might give it a shot. As it is, it just displays in the browser.
I'm not sure of where you want to save it. Put it in a completely empty
page, no <html>, <head> or <body> tags and nothing above the opening
<?php line:

<?php
header("Content-type: text/plain");

$host='host name';
$user='user name';
$pass='password';
$db='database name';

$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());

while($tblrow=mysql_fetch_row($tbls)){
$table=$tblrow[0];
$query="SELECT * FROM $table";
$result=mysql_query($query)
or die(mysql_error());
$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($types[$i]=="string")
$row[$i]="'$row[$i]'";
}
$rows[]="(".join(",",$row).")";
}
$rowstr=join(",\n",$rows);
$fields=join(",",$names);
print "# Backup of $table on ".date('m/d/Y')
." at ".date('h:i:s')."\n\n";
print "INSERT INTO $table ($fields)\nVALUES $rowstr;\n\n";
}
?>

Gary
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 18, 2007 Mar 18, 2007
Yes, thanks, Gary. I'll give that a try - although I will say that I was
slowly getting there. 8)

Standby....

--
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:5mrqv2lkpr7fa5qkqc6bbev32hjtsa9nfr@4ax.com...
> On Sun, 18 Mar 2007 09:56:18 -0400, "Murray *ACE*"
> <forums@HAHAgreat-web-sights.com> wrote:
>
>>I'm currently grieving! 8)
>>
>>Don't think you've seen the last of me....
>
>
> Murr, you still having problems with this? This isn't thoroughly tested,
> but you might give it a shot. As it is, it just displays in the browser.
> I'm not sure of where you want to save it. Put it in a completely empty
> page, no <html>, <head> or <body> tags and nothing above the opening
> <?php line:
>
> <?php
> header("Content-type: text/plain");
>
> $host='host name';
> $user='user name';
> $pass='password';
> $db='database name';
>
> $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());
>
> while($tblrow=mysql_fetch_row($tbls)){
> $table=$tblrow[0];
> $query="SELECT * FROM $table";
> $result=mysql_query($query)
> or die(mysql_error());
> $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($types[$i]=="string")
> $row[$i]="'$row[$i]'";
> }
> $rows[]="(".join(",",$row).")";
> }
> $rowstr=join(",\n",$rows);
> $fields=join(",",$names);
> print "# Backup of $table on ".date('m/d/Y')
> ." at ".date('h:i:s')."\n\n";
> print "INSERT INTO $table ($fields)\nVALUES $rowstr;\n\n";
> }
> ?>
>
> Gary


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 16, 2007 Mar 16, 2007
Murray *ACE* wrote:
> OK - I'm still getting the error. Host tells me that the folder is wide
> open. Host also wonders about one's ability to write from a SQL server to a
> local file (it's windows, in case you were wondering).
>
> Here's the error -
> Access denied for user 'wildimages'@'%' (using password: YES)

That's got nothing to do with write access, but user account access to
MySQL. You're trying to access from a different server, which isn't
allowed by the settings of the user account.

--
David Powers, Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 17, 2007 Mar 17, 2007
Yes, in the warm shower, this occurred to me. So, I'll go for the solution
that uses PHP instead of a SQL function, then....

--
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
==================


"David Powers" <david@example.com> wrote in message
news:etfk5g$6bn$1@forums.macromedia.com...
> Murray *ACE* wrote:
>> OK - I'm still getting the error. Host tells me that the folder is wide
>> open. Host also wonders about one's ability to write from a SQL server
>> to a local file (it's windows, in case you were wondering).
>>
>> Here's the error -
>> Access denied for user 'wildimages'@'%' (using password: YES)
>
> That's got nothing to do with write access, but user account access to
> MySQL. You're trying to access from a different server, which isn't
> allowed by the settings of the user account.
>
> --
> David Powers, Adobe Community Expert
> Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
> Author, "PHP Solutions" (friends of ED)
> http://foundationphp.com/


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 18, 2007 Mar 18, 2007
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
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 19, 2007 Mar 19, 2007
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


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines