<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: How to: Backup MySQL database &amp; email results using PHP</title>
	<atom:link href="http://www.sematopia.com/2006/02/how-to-backup-mysql-database-email-results-using-php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sematopia.com/2006/02/how-to-backup-mysql-database-email-results-using-php/</link>
	<description></description>
	<lastBuildDate>Fri, 12 Mar 2010 20:08:00 -0500</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: jeya</title>
		<link>http://www.sematopia.com/2006/02/how-to-backup-mysql-database-email-results-using-php/comment-page-1/#comment-196201</link>
		<dc:creator>jeya</dc:creator>
		<pubDate>Tue, 29 Sep 2009 11:38:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.sematopia.com/?p=61#comment-196201</guid>
		<description>hi

very very thanks for your database backup codings.

its very useful and correctly to work.

thanks.</description>
		<content:encoded><![CDATA[<p>hi</p>
<p>very very thanks for your database backup codings.</p>
<p>its very useful and correctly to work.</p>
<p>thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kevin</title>
		<link>http://www.sematopia.com/2006/02/how-to-backup-mysql-database-email-results-using-php/comment-page-1/#comment-194454</link>
		<dc:creator>kevin</dc:creator>
		<pubDate>Tue, 15 Sep 2009 17:17:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.sematopia.com/?p=61#comment-194454</guid>
		<description>I cann&#039;t locate the mail.php and mail/mime.php files


require_once(&#039;Mail.php&#039;);
require_once(&#039;Mail/mime.php&#039;);</description>
		<content:encoded><![CDATA[<p>I cann&#8217;t locate the mail.php and mail/mime.php files</p>
<p>require_once(&#8217;Mail.php&#8217;);<br />
require_once(&#8217;Mail/mime.php&#8217;);</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: webMultimaKer</title>
		<link>http://www.sematopia.com/2006/02/how-to-backup-mysql-database-email-results-using-php/comment-page-1/#comment-192243</link>
		<dc:creator>webMultimaKer</dc:creator>
		<pubDate>Mon, 24 Aug 2009 21:06:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.sematopia.com/?p=61#comment-192243</guid>
		<description>I had to cheat a little bit to make it work on my server, but this script really works brilliantly there too !!
Thank you all for all of your precious hints! !!

c ya !</description>
		<content:encoded><![CDATA[<p>I had to cheat a little bit to make it work on my server, but this script really works brilliantly there too !!<br />
Thank you all for all of your precious hints! !!</p>
<p>c ya !</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Darren</title>
		<link>http://www.sematopia.com/2006/02/how-to-backup-mysql-database-email-results-using-php/comment-page-1/#comment-170209</link>
		<dc:creator>Darren</dc:creator>
		<pubDate>Thu, 19 Feb 2009 13:15:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.sematopia.com/?p=61#comment-170209</guid>
		<description>Spent a while looking at options for backing up db&#039;s from shared hosting and this worked brilliantly here. Thanks for sharing.</description>
		<content:encoded><![CDATA[<p>Spent a while looking at options for backing up db&#8217;s from shared hosting and this worked brilliantly here. Thanks for sharing.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew</title>
		<link>http://www.sematopia.com/2006/02/how-to-backup-mysql-database-email-results-using-php/comment-page-1/#comment-152742</link>
		<dc:creator>Andrew</dc:creator>
		<pubDate>Thu, 11 Dec 2008 21:00:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.sematopia.com/?p=61#comment-152742</guid>
		<description>Cool idea.  Having it in a PHP script will let people use it that doesn&#039;t have shell access to their hosting account, as long as the exec() statement is available.  The only thing is, storing it locally is better than emailing it because emailing anything is insecure, unless it&#039;s encrypted.

There is also a shell script solution out there called AutoMySQLBackup, found here: http://members.lycos.co.uk/wipe_out/automysqlbackup/</description>
		<content:encoded><![CDATA[<p>Cool idea.  Having it in a PHP script will let people use it that doesn&#8217;t have shell access to their hosting account, as long as the exec() statement is available.  The only thing is, storing it locally is better than emailing it because emailing anything is insecure, unless it&#8217;s encrypted.</p>
<p>There is also a shell script solution out there called AutoMySQLBackup, found here: <a href="http://members.lycos.co.uk/wipe_out/automysqlbackup/" rel="nofollow">http://members.lycos.co.uk/wipe_out/automysqlbackup/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Audrey</title>
		<link>http://www.sematopia.com/2006/02/how-to-backup-mysql-database-email-results-using-php/comment-page-1/#comment-145353</link>
		<dc:creator>Audrey</dc:creator>
		<pubDate>Wed, 12 Nov 2008 17:26:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.sematopia.com/?p=61#comment-145353</guid>
		<description>Hello,

What a great way to do backups! I tried to implement the script and had a problem...I was hoping you could help. I don&#039;t have permission to write to my /tmp file (I&#039;m on a shared server), so I created a folder within my httpdocs called tmp. While the program can write to the folder, it cannot seem to create the files on the fly, and therefore gives the error 

unlink(filepath..../tmp/db_2008_11_12.sql) [function.unlink]: No such file or directory 

When I create the files FIRST, manually, i.e. db_2008_11_12.sql and db_2008_11_12.tgz in that directory, I do not get the error, but the resulting file that is emailed to me is unreadable (db_2008_11_12.tgz)

thanks for any help you can provide!</description>
		<content:encoded><![CDATA[<p>Hello,</p>
<p>What a great way to do backups! I tried to implement the script and had a problem&#8230;I was hoping you could help. I don&#8217;t have permission to write to my /tmp file (I&#8217;m on a shared server), so I created a folder within my httpdocs called tmp. While the program can write to the folder, it cannot seem to create the files on the fly, and therefore gives the error </p>
<p>unlink(filepath&#8230;./tmp/db_2008_11_12.sql) [function.unlink]: No such file or directory </p>
<p>When I create the files FIRST, manually, i.e. db_2008_11_12.sql and db_2008_11_12.tgz in that directory, I do not get the error, but the resulting file that is emailed to me is unreadable (db_2008_11_12.tgz)</p>
<p>thanks for any help you can provide!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: vihutuo</title>
		<link>http://www.sematopia.com/2006/02/how-to-backup-mysql-database-email-results-using-php/comment-page-1/#comment-138185</link>
		<dc:creator>vihutuo</dc:creator>
		<pubDate>Sat, 18 Oct 2008 05:05:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.sematopia.com/?p=61#comment-138185</guid>
		<description>Nice script. Though some web hosts do provide back ups of our database many shared web hosting providers don&#039;t. I am also in the process of moving one of my sites</description>
		<content:encoded><![CDATA[<p>Nice script. Though some web hosts do provide back ups of our database many shared web hosting providers don&#8217;t. I am also in the process of moving one of my sites</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sean</title>
		<link>http://www.sematopia.com/2006/02/how-to-backup-mysql-database-email-results-using-php/comment-page-1/#comment-120731</link>
		<dc:creator>Sean</dc:creator>
		<pubDate>Thu, 21 Aug 2008 20:16:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.sematopia.com/?p=61#comment-120731</guid>
		<description>My coworker pointed me to this script.  We modified it with an PHPMailer and it works great.  It is being used to back up Media Temple databases for us.  I created an array of the databases that we want to back up and it loops through and sends an email for each.

Great job.</description>
		<content:encoded><![CDATA[<p>My coworker pointed me to this script.  We modified it with an PHPMailer and it works great.  It is being used to back up Media Temple databases for us.  I created an array of the databases that we want to back up and it loops through and sends an email for each.</p>
<p>Great job.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ozman</title>
		<link>http://www.sematopia.com/2006/02/how-to-backup-mysql-database-email-results-using-php/comment-page-1/#comment-113864</link>
		<dc:creator>ozman</dc:creator>
		<pubDate>Sat, 02 Aug 2008 21:08:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.sematopia.com/?p=61#comment-113864</guid>
		<description>Previous post has SMTP auth</description>
		<content:encoded><![CDATA[<p>Previous post has SMTP auth</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ozman</title>
		<link>http://www.sematopia.com/2006/02/how-to-backup-mysql-database-email-results-using-php/comment-page-1/#comment-113863</link>
		<dc:creator>ozman</dc:creator>
		<pubDate>Sat, 02 Aug 2008 21:07:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.sematopia.com/?p=61#comment-113863</guid>
		<description>if you can&#039;t use mysqldump try this

&lt;?php

require_once &quot;Mail.php&quot;;
require_once(&#039;Mail/mime.php&#039;);

/*************** Modify database settings ***************/

$Host = &quot;MYSQL-HOST&quot;;
$UserName = &#039;MYSQL-USER&#039;;
$Password = &#039;MYSQL-PASSWORD&#039;;
$Database = &#039;MYSQL-DATABASE&#039;;
$tmpDir = &quot;/tmp/&quot;;
/*************** Modify email settings ***************/
//$from = $_POST[&quot;From&quot;] or die(&quot;NO From Address&quot;);
//$to = $_POST[&quot;To&quot;] or die(&quot;NO To Address&quot;);

$from = &quot;webmaster Sender &quot;;
$to = &quot;webmaster Recipient &quot;;
$subject = &quot;$Database - backup&quot;;

$ehost = &quot;smtp.EXAMPLE.com&quot;;
$eusername = &quot;webmaster@EXAMPLE.com&quot;;
$epassword = &quot;PASSWORD&quot;;

/*************** Do not modify below this line ***************/

$connection = mysql_connect(&quot;$Host&quot;,&quot;$UserName&quot;,&quot;$Password&quot;);
mysql_select_db($Database, $connection);
$sql = &#039;SHOW TABLES FROM &#039;.$Database;
$result = mysql_query($sql);
$contents = &quot;-- Created By: My Database Mailer\n-- Copyright: Aaron St.Clair McMurray\n-- http://www.ourfreeinfo.com\n\n-- Database: &quot;.$Database.&quot;\n-- Created: &quot;.date(&#039;M j, Y&#039;).&quot; at &quot;.date(&#039;h:i A&#039;).&quot;\n\n&quot;;
while ($tables = mysql_fetch_array($result)) {
    $TableList[] = $tables[0];
}
foreach ($TableList as $table) {
    $row = mysql_fetch_assoc(mysql_query(&#039;SHOW CREATE TABLE &#039;.$table));
    $contents .= $row[&quot;Create Table&quot;].&quot;;\n\n&quot;;
    $sql = &#039;SELECT * FROM &#039;.$table;
    $result = mysql_query($sql);
    $columns = explode(&#039;,&#039;,$row[&quot;Create Table&quot;]);
    $i = 0;
    while ($records = mysql_fetch_array($result)) {
        $contents .= &quot;INSERT INTO &quot;.$table.&quot; VALUES (&quot;;
        for ($i=0;$i&lt; count($records)/2;$i++) {
            if ($i  $from, &#039;To&#039; =&gt; $to, &#039;Subject&#039; =&gt; $subject);


    $textMessage = $attachment;
    $htmlMessage = &quot;&quot;;

    $mime = new Mail_Mime(&quot;\n&quot;);
    $mime-&gt;setTxtBody($textMessage);
    $mime-&gt;setHtmlBody($htmlMessage);
    $mime-&gt;addAttachment($attachment, &#039;text/plain&#039;);
    $body = $mime-&gt;get();
    $hdrs = $mime-&gt;headers($headers);
    $mail = Mail::factory(&#039;smtp&#039;,
    array (&#039;host&#039; =&gt; $ehost,
    &#039;auth&#039; =&gt; true,
    &#039;username&#039; =&gt; $eusername,
    &#039;password&#039; =&gt; $epassword));
    $mail-&gt;send($to, $hdrs, $body);

    unlink($sqlFile);
    unlink($attachment);


if (PEAR::isError($mail)) {
  echo(&quot;&quot; . $mail-&gt;getMessage() . &quot;&quot;);
 } else {
  echo(&quot;$sqlFile Message successfully sent!&quot;);
 }

mysql_close($connection);


?&gt;</description>
		<content:encoded><![CDATA[<p>if you can&#8217;t use mysqldump try this</p>
<p>&lt;?php</p>
<p>require_once &#8220;Mail.php&#8221;;<br />
require_once(&#8217;Mail/mime.php&#8217;);</p>
<p>/*************** Modify database settings ***************/</p>
<p>$Host = &#8220;MYSQL-HOST&#8221;;<br />
$UserName = &#8216;MYSQL-USER&#8217;;<br />
$Password = &#8216;MYSQL-PASSWORD&#8217;;<br />
$Database = &#8216;MYSQL-DATABASE&#8217;;<br />
$tmpDir = &#8220;/tmp/&#8221;;<br />
/*************** Modify email settings ***************/<br />
//$from = $_POST["From"] or die(&#8221;NO From Address&#8221;);<br />
//$to = $_POST["To"] or die(&#8221;NO To Address&#8221;);</p>
<p>$from = &#8220;webmaster Sender &#8220;;<br />
$to = &#8220;webmaster Recipient &#8220;;<br />
$subject = &#8220;$Database &#8211; backup&#8221;;</p>
<p>$ehost = &#8220;smtp.EXAMPLE.com&#8221;;<br />
$eusername = &#8220;webmaster@EXAMPLE.com&#8221;;<br />
$epassword = &#8220;PASSWORD&#8221;;</p>
<p>/*************** Do not modify below this line ***************/</p>
<p>$connection = mysql_connect(&#8221;$Host&#8221;,&#8221;$UserName&#8221;,&#8221;$Password&#8221;);<br />
mysql_select_db($Database, $connection);<br />
$sql = &#8216;SHOW TABLES FROM &#8216;.$Database;<br />
$result = mysql_query($sql);<br />
$contents = &#8220;&#8211; Created By: My Database Mailer\n&#8211; Copyright: Aaron St.Clair McMurray\n&#8211; <a href="http://www.ourfreeinfo.com" rel="nofollow">http://www.ourfreeinfo.com</a>\n\n&#8211; Database: &#8220;.$Database.&#8221;\n&#8211; Created: &#8220;.date(&#8217;M j, Y&#8217;).&#8221; at &#8220;.date(&#8217;h:i A&#8217;).&#8221;\n\n&#8221;;<br />
while ($tables = mysql_fetch_array($result)) {<br />
    $TableList[] = $tables[0];<br />
}<br />
foreach ($TableList as $table) {<br />
    $row = mysql_fetch_assoc(mysql_query(&#8217;SHOW CREATE TABLE &#8216;.$table));<br />
    $contents .= $row["Create Table"].&#8221;;\n\n&#8221;;<br />
    $sql = &#8216;SELECT * FROM &#8216;.$table;<br />
    $result = mysql_query($sql);<br />
    $columns = explode(&#8217;,',$row["Create Table"]);<br />
    $i = 0;<br />
    while ($records = mysql_fetch_array($result)) {<br />
        $contents .= &#8220;INSERT INTO &#8220;.$table.&#8221; VALUES (&#8221;;<br />
        for ($i=0;$i&lt; count($records)/2;$i++) {<br />
            if ($i  $from, &#8216;To&#8217; =&gt; $to, &#8216;Subject&#8217; =&gt; $subject);</p>
<p>    $textMessage = $attachment;<br />
    $htmlMessage = &#8220;&#8221;;</p>
<p>    $mime = new Mail_Mime(&#8221;\n&#8221;);<br />
    $mime-&gt;setTxtBody($textMessage);<br />
    $mime-&gt;setHtmlBody($htmlMessage);<br />
    $mime-&gt;addAttachment($attachment, &#8216;text/plain&#8217;);<br />
    $body = $mime-&gt;get();<br />
    $hdrs = $mime-&gt;headers($headers);<br />
    $mail = Mail::factory(&#8217;smtp&#8217;,<br />
    array (&#8217;host&#8217; =&gt; $ehost,<br />
    &#8216;auth&#8217; =&gt; true,<br />
    &#8216;username&#8217; =&gt; $eusername,<br />
    &#8216;password&#8217; =&gt; $epassword));<br />
    $mail-&gt;send($to, $hdrs, $body);</p>
<p>    unlink($sqlFile);<br />
    unlink($attachment);</p>
<p>if (PEAR::isError($mail)) {<br />
  echo(&#8221;" . $mail-&gt;getMessage() . &#8220;&#8221;);<br />
 } else {<br />
  echo(&#8221;$sqlFile Message successfully sent!&#8221;);<br />
 }</p>
<p>mysql_close($connection);</p>
<p>?&gt;</p>
]]></content:encoded>
	</item>
</channel>
</rss>
