<?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: mysqldump &#8211; with exec() function from php outputs empty file</title>
	<atom:link href="http://www.theerrormessage.com/2008/10/mysqldump-with-exec-function-from-php-outputs-empty-file/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.theerrormessage.com/2008/10/mysqldump-with-exec-function-from-php-outputs-empty-file/</link>
	<description>Fix your error</description>
	<lastBuildDate>Wed, 11 Jan 2012 15:12:15 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.5</generator>
	<item>
		<title>By: Cheap Shared Hosting</title>
		<link>http://www.theerrormessage.com/2008/10/mysqldump-with-exec-function-from-php-outputs-empty-file/comment-page-1/#comment-18872</link>
		<dc:creator>Cheap Shared Hosting</dc:creator>
		<pubDate>Sat, 17 Apr 2010 20:17:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.theerrormessage.com/2008/10/21/mysqldump-with-exec-function-from-php-outputs-empty-file/#comment-18872</guid>
		<description>I&#039;m unsure if I agree with everything written but this was definitely informative and well-written.</description>
		<content:encoded><![CDATA[<p>I&#8217;m unsure if I agree with everything written but this was definitely informative and well-written.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: admin</title>
		<link>http://www.theerrormessage.com/2008/10/mysqldump-with-exec-function-from-php-outputs-empty-file/comment-page-1/#comment-4921</link>
		<dc:creator>admin</dc:creator>
		<pubDate>Tue, 27 Oct 2009 14:33:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.theerrormessage.com/2008/10/21/mysqldump-with-exec-function-from-php-outputs-empty-file/#comment-4921</guid>
		<description>Did you check that the paths are correctly entered?

$command = &quot;/path/to/mysqldump --opt --skip-extended-insert --complete-insert --host=&quot;.$DB_HOST.&quot; --user=&quot;.$DB_USER.&quot; --password=&quot;.$DB_PASS.&quot; &quot;.$DB_NAME.&quot; &gt; /path/to/backup.sql&quot;;</description>
		<content:encoded><![CDATA[<p>Did you check that the paths are correctly entered?</p>
<p>$command = &#8220;/path/to/mysqldump &#8211;opt &#8211;skip-extended-insert &#8211;complete-insert &#8211;host=&#8221;.$DB_HOST.&#8221; &#8211;user=&#8221;.$DB_USER.&#8221; &#8211;password=&#8221;.$DB_PASS.&#8221; &#8220;.$DB_NAME.&#8221; > /path/to/backup.sql&#8221;;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: wordio</title>
		<link>http://www.theerrormessage.com/2008/10/mysqldump-with-exec-function-from-php-outputs-empty-file/comment-page-1/#comment-4920</link>
		<dc:creator>wordio</dc:creator>
		<pubDate>Tue, 27 Oct 2009 14:22:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.theerrormessage.com/2008/10/21/mysqldump-with-exec-function-from-php-outputs-empty-file/#comment-4920</guid>
		<description>do you have a solution for linux too ?</description>
		<content:encoded><![CDATA[<p>do you have a solution for linux too ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: admin</title>
		<link>http://www.theerrormessage.com/2008/10/mysqldump-with-exec-function-from-php-outputs-empty-file/comment-page-1/#comment-608</link>
		<dc:creator>admin</dc:creator>
		<pubDate>Fri, 20 Feb 2009 19:26:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.theerrormessage.com/2008/10/21/mysqldump-with-exec-function-from-php-outputs-empty-file/#comment-608</guid>
		<description>&lt;p&gt;Maybe you should try with the long commands for &quot;-f -C -K&quot; like this:&lt;/p&gt;
&lt;pre&gt;&quot;--force --compress --disable-keys --host={$host} --user={$user} --password={$pass} &quot; &lt;/pre&gt;

</description>
		<content:encoded><![CDATA[<p>Maybe you should try with the long commands for &#8220;-f -C -K&#8221; like this:</p>
<pre>"--force --compress --disable-keys --host={$host} --user={$user} --password={$pass} " </pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ray</title>
		<link>http://www.theerrormessage.com/2008/10/mysqldump-with-exec-function-from-php-outputs-empty-file/comment-page-1/#comment-604</link>
		<dc:creator>Ray</dc:creator>
		<pubDate>Fri, 20 Feb 2009 18:12:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.theerrormessage.com/2008/10/21/mysqldump-with-exec-function-from-php-outputs-empty-file/#comment-604</guid>
		<description>Here is the code I wrote that proves this...
isAuthorized())
		{
			$this-&gt;redirect($this-&gt;getConfig(&#039;login_page&#039;));
		}

		// Get requirements and verify they loaded correctly
		if (!stristr($_SERVER[&#039;HTTP_REFERER&#039;], &#039;pages/adminManager.php&#039;))
		{
			$this-&gt;append($this-&gt;error(&#039;Access denied to this location&#039;));

			return;
		}

		// Get the database credentials
		$db = new db();
		$host = $db-&gt;getHost();
		$dbname = $db-&gt;getDbName();
		$user = $db-&gt;getUserName();
		$pass = $db-&gt;getPass();

		// Create the dump filename
		$date = date(&#039;h:i:s--m-d-Y&#039;);
		$backup_path = &quot;../db_dumps/{$host}-{$dbname}-{$date}.sql&quot;;

		// Attempt the backup for a Linux environment
		$command = &quot;mysqldump -f -C -K --host={$host} --user={$user} --password={$pass} $dbname &gt;{$backup_path}&quot;;
		exec($command, $output, $error_code);

		// Check for errors
		if ($error_code != 0)
		{
			// Get the path to the mysqldump program
			$command = &#039;dir /b/s \mysqldump.exe&#039;;
			exec($command, $output, $error_code);

			// Check for errors
			if ($error_code != 0)
			{
				// Something is wrong but we don&#039;t know what
				$this-&gt;append($this-&gt;error(&quot;$command failed with an error code of $error_code&quot;));

				return;
			}

			// Windows refuses to work with dashes and or colons in the file name
			$date = date(&#039;hismdY&#039;);
			$base_path = $this-&gt;getConfig(&#039;base_dir&#039;);
			$backup_path = &quot;{$base_path}db_dumps/{$host}{$dbname}{$date}.sql&quot;;

			// Windows needs back slash paths instead of forward slash paths
			$path_array = explode(&#039;/&#039;, $backup_path);
			$backup_path = implode(&#039;\\&#039;, $path_array);
		
			// Attempt the backup for a Windows environment
			$command = &quot;\&quot;{$output[0]}\&quot; -f -C -K --host={$host} --user={$user} --password={$pass} $dbname &gt;\&quot;{$backup_path}\&quot;&quot;;
			exec($command, $output, $error_code);

			// Check for errrors
			if ($error_code != 0)
			{
				// Something is wrong but we don&#039;t know what
				$this-&gt;append($this-&gt;error(&quot;$command failed with an error code of $error_code&quot;));

				return;
			}
			if (!file_exists($backup_path))
			{
				// The file that needs to be created cannot be
				$this-&gt;append($this-&gt;error(&quot;The path $backup_path, does not exist&quot;));

				return;
			}
			if (sizeof($backup_path) == 0)
			{
				// The file was created but no data was written to it
				$this-&gt;append($this-&gt;error(&quot;The backup file was created but not filled. Try running the command $command from cmd.&quot;));

				return;
			}

		}

		header(&quot;Location: {$_SERVER[&#039;HTTP_REFERER&#039;]}&quot;);
	}
}

$db_dump = new dbDump();
?&gt;</description>
		<content:encoded><![CDATA[<p>Here is the code I wrote that proves this&#8230;<br />
isAuthorized())<br />
		{<br />
			$this-&gt;redirect($this-&gt;getConfig(&#8216;login_page&#8217;));<br />
		}</p>
<p>		// Get requirements and verify they loaded correctly<br />
		if (!stristr($_SERVER['HTTP_REFERER'], &#8216;pages/adminManager.php&#8217;))<br />
		{<br />
			$this-&gt;append($this-&gt;error(&#8216;Access denied to this location&#8217;));</p>
<p>			return;<br />
		}</p>
<p>		// Get the database credentials<br />
		$db = new db();<br />
		$host = $db-&gt;getHost();<br />
		$dbname = $db-&gt;getDbName();<br />
		$user = $db-&gt;getUserName();<br />
		$pass = $db-&gt;getPass();</p>
<p>		// Create the dump filename<br />
		$date = date(&#8216;h:i:s&#8211;m-d-Y&#8217;);<br />
		$backup_path = &#8220;../db_dumps/{$host}-{$dbname}-{$date}.sql&#8221;;</p>
<p>		// Attempt the backup for a Linux environment<br />
		$command = &#8220;mysqldump -f -C -K &#8211;host={$host} &#8211;user={$user} &#8211;password={$pass} $dbname &gt;{$backup_path}&#8221;;<br />
		exec($command, $output, $error_code);</p>
<p>		// Check for errors<br />
		if ($error_code != 0)<br />
		{<br />
			// Get the path to the mysqldump program<br />
			$command = &#8216;dir /b/s \mysqldump.exe&#8217;;<br />
			exec($command, $output, $error_code);</p>
<p>			// Check for errors<br />
			if ($error_code != 0)<br />
			{<br />
				// Something is wrong but we don&#8217;t know what<br />
				$this-&gt;append($this-&gt;error(&#8220;$command failed with an error code of $error_code&#8221;));</p>
<p>				return;<br />
			}</p>
<p>			// Windows refuses to work with dashes and or colons in the file name<br />
			$date = date(&#8216;hismdY&#8217;);<br />
			$base_path = $this-&gt;getConfig(&#8216;base_dir&#8217;);<br />
			$backup_path = &#8220;{$base_path}db_dumps/{$host}{$dbname}{$date}.sql&#8221;;</p>
<p>			// Windows needs back slash paths instead of forward slash paths<br />
			$path_array = explode(&#8216;/&#8217;, $backup_path);<br />
			$backup_path = implode(&#8216;\\&#8217;, $path_array);</p>
<p>			// Attempt the backup for a Windows environment<br />
			$command = &#8220;\&#8221;{$output[0]}\&#8221; -f -C -K &#8211;host={$host} &#8211;user={$user} &#8211;password={$pass} $dbname &gt;\&#8221;{$backup_path}\&#8221;";<br />
			exec($command, $output, $error_code);</p>
<p>			// Check for errrors<br />
			if ($error_code != 0)<br />
			{<br />
				// Something is wrong but we don&#8217;t know what<br />
				$this-&gt;append($this-&gt;error(&#8220;$command failed with an error code of $error_code&#8221;));</p>
<p>				return;<br />
			}<br />
			if (!file_exists($backup_path))<br />
			{<br />
				// The file that needs to be created cannot be<br />
				$this-&gt;append($this-&gt;error(&#8220;The path $backup_path, does not exist&#8221;));</p>
<p>				return;<br />
			}<br />
			if (sizeof($backup_path) == 0)<br />
			{<br />
				// The file was created but no data was written to it<br />
				$this-&gt;append($this-&gt;error(&#8220;The backup file was created but not filled. Try running the command $command from cmd.&#8221;));</p>
<p>				return;<br />
			}</p>
<p>		}</p>
<p>		header(&#8220;Location: {$_SERVER['HTTP_REFERER']}&#8221;);<br />
	}<br />
}</p>
<p>$db_dump = new dbDump();<br />
?&gt;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ray</title>
		<link>http://www.theerrormessage.com/2008/10/mysqldump-with-exec-function-from-php-outputs-empty-file/comment-page-1/#comment-603</link>
		<dc:creator>Ray</dc:creator>
		<pubDate>Fri, 20 Feb 2009 18:12:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.theerrormessage.com/2008/10/21/mysqldump-with-exec-function-from-php-outputs-empty-file/#comment-603</guid>
		<description>No, this doesn&#039;t work...in Windows</description>
		<content:encoded><![CDATA[<p>No, this doesn&#8217;t work&#8230;in Windows</p>
]]></content:encoded>
	</item>
</channel>
</rss>

