<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Webmaster-Source &#187; mysql</title>
	<atom:link href="https://www.webmaster-source.com/tag/mysql/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.webmaster-source.com</link>
	<description>Useful Resources For Webmasters</description>
	<lastBuildDate>Thu, 24 Aug 2017 02:01:18 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.1.42</generator>
	<item>
		<title>Bobby-Tables.com: A guide to preventing SQL injection</title>
		<link>https://www.webmaster-source.com/2012/04/11/bobby-tables-com-a-guide-to-preventing-sql-injection/</link>
		<comments>https://www.webmaster-source.com/2012/04/11/bobby-tables-com-a-guide-to-preventing-sql-injection/#comments</comments>
		<pubDate>Wed, 11 Apr 2012 11:57:27 +0000</pubDate>
		<dc:creator><![CDATA[Matt]]></dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[SQL injection]]></category>

		<guid isPermaLink="false">http://www.webmaster-source.com/?p=4559</guid>
		<description><![CDATA[SQL injection: still one of the more common exploits against web applications, and yet it is one of the easier ones to guard against. Unfortunately, bad tutorials often teach newbie developers bad habits that enable injection attacks, rather than using more secure methods of interacting with databases. Yes, PHP often gets a lot of flak [&#8230;]]]></description>
				<content:encoded><![CDATA[<p><a href="http://xkcd.com/327/"><img style=' float: right; padding: 4px; margin: 0 0 2px 7px;'  class="alignright size-full wp-image-4214" title="XKCD: Bobby Tables" src="//www.webmaster-source.com/wp-content/uploads/xkcd-bobby-tables.png" alt="" width="124" height="147" /></a>SQL injection: still one of the more common exploits against web applications, and yet it is one of the easier ones to guard against. Unfortunately, bad tutorials often teach newbie developers bad habits that enable injection attacks, rather than using more secure methods of interacting with databases.</p>
<p>Yes, PHP often gets a lot of flak for this, as its status as an introductory languages makes for a greater number of subpar coders and introductory tutorials, but SQL injection is by no means a &#8220;PHP thing.&#8221; Actually, there are probably <em>more</em> resources warning about SQL injection for PHP than other languages&#8230;</p>
<p>Wouldn&#8217;t it be useful if there was one resource you could point people to in order to explain SQL injection and show some examples of best practices in their language of choice?</p>
<p><a href="http://bobby-tables.com/">Bobby-Tables.com</a> has examples of safe methods to handle database interaction in several languages, including PHP, Python, C#, Ruby and Java. Plus, it gets bonus points for referencing the relevant <a href="http://xkcd.com/">XKCD</a> comic. (There really is one for every occasion, isn&#8217;t there?)</p>
]]></content:encoded>
			<wfw:commentRss>https://www.webmaster-source.com/2012/04/11/bobby-tables-com-a-guide-to-preventing-sql-injection/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to Import a Very Large SQL Dump with phpMyAdmin</title>
		<link>https://www.webmaster-source.com/2011/09/26/how-to-import-a-very-large-sql-dump-with-phpmyadmin/</link>
		<comments>https://www.webmaster-source.com/2011/09/26/how-to-import-a-very-large-sql-dump-with-phpmyadmin/#comments</comments>
		<pubDate>Mon, 26 Sep 2011 12:37:04 +0000</pubDate>
		<dc:creator><![CDATA[Matt]]></dc:creator>
				<category><![CDATA[Software & Scripts]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://www.webmaster-source.com/?p=4303</guid>
		<description><![CDATA[Having trouble importing a large SQL dump through phpMyAdmin? This is a problem that often plagues users of shared web hosting, when they&#8217;re moving to a new host or restoring a backup. Since most shared hosting providers don&#8217;t offer shell access, you have to use a tool like phpMyAdmin to upload and load your SQL [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Having trouble importing a large SQL dump through phpMyAdmin? This is a problem that often plagues users of shared web hosting, when they&#8217;re moving to a new host or <a href="http://codex.wordpress.org/Restoring_Your_Database_From_Backup">restoring a backup</a>. Since most shared hosting providers don&#8217;t offer shell access, you have to use a tool like phpMyAdmin to upload and load your SQL file.</p>
<p>Unfortunately, phpMyAdmin often has trouble processing large files. Sometimes it takes so long for the process to run that it times out, or other times the upload quota is simply too low.</p>
<p>Fortunately, there&#8217;s a simple solution: split your SQL file into smaller chunks. Here&#8217;s a command you can use under Mac OS X or Linux to do it automatically:</p>
<p><code>split -l 5000 ./path/to/mysqldump.sql ./mysqldump/dbpart-</code></p>
<p>The <em>split</em> command takes a file and breaks it into multiple files. The <em>-l 5000</em> part tells it to split the file every five thousand lines. (You can tweak this value to find a good medium between fewer files and larger sizes.) The next bit is the path to your file, and the next part is the path you want to save the output to. Files will be saved as whatever filename you specify (e.g. &#8220;dbpart-&#8220;) with an alphabetical letter combination appended.</p>
<p>Now you should be able to import your files one at a time through phpMyAdmin without issue.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.webmaster-source.com/2011/09/26/how-to-import-a-very-large-sql-dump-with-phpmyadmin/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Getting Your Feet Wet with PDO and Migrating Old MySQL Code</title>
		<link>https://www.webmaster-source.com/2011/08/05/getting-your-feet-wet-with-pdo-and-migrating-old-mysql-code/</link>
		<comments>https://www.webmaster-source.com/2011/08/05/getting-your-feet-wet-with-pdo-and-migrating-old-mysql-code/#comments</comments>
		<pubDate>Fri, 05 Aug 2011 12:33:16 +0000</pubDate>
		<dc:creator><![CDATA[Matt]]></dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[SQL injection]]></category>

		<guid isPermaLink="false">http://www.webmaster-source.com/?p=4213</guid>
		<description><![CDATA[You may have heard that the old MySQL extension for PHP is going to eventually be deprecated in favor of the newer (and potentially more secure) MySQLi and PDO extensions. You&#8217;re going to need to update your old code sooner or later, so why not make it sooner? I&#8217;m going to recommend PDO over MySQLi [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>You may have heard that the old MySQL extension for PHP is going to <a href="http://www.webmaster-source.com/2011/07/25/php-to-deprecate-mysql-extension-in-favor-of-mysqli-and-pdo/">eventually be deprecated</a> in favor of the newer (and potentially more secure) MySQLi and PDO extensions. You&#8217;re going to need to update your old code sooner or later, so why not make it sooner?</p>
<p>I&#8217;m going to recommend <a href="http://php.net/manual/en/book.pdo.php">PDO</a> over <a href="http://www.php.net/manual/en/book.mysqli.php">MySQLi</a> simply because it&#8217;s available on more systems, and it&#8217;s syntax may be a little bit easier to learn for newbies. PDO has been bundled with the main PHP distribution since PHP 5.1, and has been in PECL even longer, while MySQLi has only been included since 5.3. Whichever you use is up to personal preference and project requirements of course, but I will be sticking with PDO for the duration of this tutorial.<span id="more-4213"></span></p>
<p>Suppose you have a simple bit of PHP that executes a MySQL query and ouputs a list of items to screen. It might look something like this:</p>
<pre class="brush: php; title: ; notranslate">
    $db = mysql_connect(&quot;localhost&quot;, &quot;username&quot;, &quot;password&quot;);
    mysql_select_db(&quot;database&quot;, $db);

    $string = mysql_real_escape_string($string, $db);
    $query = &quot;SELECT * FROM my_table WHERE item_cat='&quot;.$string.&quot;' ORDER BY item_date DESC LIMIT 5&quot;;
    $result = mysql_query($query);

    if ( mysql_num_rows($result) &gt; 0 ) {
        while ( $row = mysql_fetch_assoc($result) ) {
            echo $row['item_title'] . '&lt;br /&gt;';
        }
    }
</pre>
<p><a href="http://xkcd.com/327/"><img style=' float: right; padding: 4px; margin: 0 0 2px 7px;'  class="alignright size-full wp-image-4214" title="XKCD: Bobby Tables" src="//www.webmaster-source.com/wp-content/uploads/xkcd-bobby-tables.png" alt="" width="124" height="147" /></a>You&#8217;re escaping any input from a third party with mysql_real_escape_string() to prevent injection attacks, I hope. <a href="http://en.wikipedia.org/wiki/Sql_injection">SQL injection</a> is one of the most common ways data is stolen or destroyed by attackers, and it&#8217;s also fairly easy to discourage. Escaping input, while not necessarily 100% effective, should prevent most injection attacks. (And it&#8217;s pretty much your only choice with the old MySQL extension.) A better solution is parameterized statements, which we&#8217;ll get to later.</p>
<p>If your server has PDO installed (which is probably the case if you have PHP 5.1 or greater), migrating is fairly easy. The basic principles are the same, though the syntax differs just a bit. It&#8217;s actually a bit cleaner and more object-oriented.</p>
<p>The example above would look something like this:</p>
<pre class="brush: php; title: ; notranslate">
$db = new pdo(&quot;mysql:host=localhost;dbname=database_name&quot;, &quot;username&quot;, &quot;password&quot;);
$string = $db-&gt;quote($string);
$query = &quot;SELECT * FROM my_table WHERE item_cat=$string ORDER BY item_date DESC LIMIT 5&quot;;
$result = $db-&gt;query($query);

if ($result != false) {
    while ( $row = $result-&gt;fetch(PDO::FETCH_ASSOC) ) {
        echo $row['item_title'] . '&lt;br /&gt;';
    }
}

$result  = null;
</pre>
<p>Doesn&#8217;t that look nicer? Feel free to take a moment to appreciate the object-oriented goodness.</p>
<p>The biggest difference is probably the connection line. The &#8220;DSN&#8221; syntax used to connect to the database might look a bit strange at first, but it&#8217;s an important part of PDO. Since PDO can connect to other types of databases besides MySQL (e.g. PostgreSQL and SQLite), it uses a fairly standard connection string that specifies the server type besides the database name.</p>
<p>Escaping strings works essentially the same, but the syntax is slightly different. You need to remember to not put quotes around the variable in your SQL string, as the PDO::quote() method will do it for you. If you compare the SQL statements in the two examples, you&#8217;ll see the lack of quotations in the PDO example.</p>
<p>One gotcha to be aware of with PDO is that you need to set your $result variable to <em>null</em> if you intend to reuse it later on in the same script. You can end up with some weird results if you don&#8217;t. So just get in the habit of setting it to <em>null</em> or using unset() on it.</p>
<p>Now how about those <a href="http://www.php.net/manual/en/pdo.prepare.php">parameterized statement</a> things? They&#8217;re a way of ensuring that your code will be immune to SQL injection. Instead of mashing PHP strings together and passing the resulting query to the database engine, you keep the query and the potentially dangerous data separate. Placeholders are put in the query, and the data assigned to those placeholders is sent along with it.</p>
<pre class="brush: php; title: ; notranslate">
$db = new pdo(&quot;mysql:host=localhost;dbname=database_name&quot;, &quot;username&quot;, &quot;password&quot;);

$sql = &quot;SELECT * FROM my_table WHERE item_cat= :mystring ORDER BY item_date DESC LIMIT 5&quot;;
$statement = $db-&gt;prepare($sql);

$statement-&gt;execute(array(
    ':mystring' =&gt; $my_string
));

$result = $statement-&gt;fetchAll();

if ($result != false) {
    while ( $row = $result-&gt;fetch(PDO::FETCH_ASSOC) ) {
        echo $row['item_title'] . '&lt;br /&gt;';
    }
}

$result  = null;
</pre>
<p>Parameterized queries may have some performance issues on MySQL versions prior to 5.1, but they shouldn&#8217;t have any significant disadvantages on more modern systems. Security-wise, they&#8217;re considered to be better than simply escaping strings.</p>
<p>I hope this little guide has been sufficient to get you started with PDO. You will probably want to c<a href="http://php.net/manual/en/book.pdo.php">heck out the documentation</a> to see what else it can do. While you don&#8217;t necessarily need to go out and update your old code right away—the PHP devs aren&#8217;t going to drop support for the old ext/mysql extension for quite a long time, if they ever get rid of it completely—but you should definitely familiarize yourself with the newer techniques and use them in new projects.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.webmaster-source.com/2011/08/05/getting-your-feet-wet-with-pdo-and-migrating-old-mysql-code/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Automatic Amazon S3 Backups on Ubuntu/Debian</title>
		<link>https://www.webmaster-source.com/2010/03/15/automatic-amazon-s3-backups-on-ubuntudebian/</link>
		<comments>https://www.webmaster-source.com/2010/03/15/automatic-amazon-s3-backups-on-ubuntudebian/#comments</comments>
		<pubDate>Mon, 15 Mar 2010 11:50:11 +0000</pubDate>
		<dc:creator><![CDATA[Matt]]></dc:creator>
				<category><![CDATA[Hosting]]></category>
		<category><![CDATA[Amazon]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[cron]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[S3]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.webmaster-source.com/?p=3127</guid>
		<description><![CDATA[If you manage your own web server, as you do with a VPS, one thing you need to look into is a backup strategy. It wouldn&#8217;t be pleasant for your files to vanish into the ether in the event of some sort of catastrophic server meltdown, would it? Optimally you want to, on a daily [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>If you manage your own web server, as you do with a VPS, one thing you need to look into is a backup strategy. It wouldn&#8217;t be pleasant for your files to vanish into the ether in the event of some sort of catastrophic server meltdown, would it? Optimally you want to, on a daily basis, offload a copy of everything important to a separate geographical location. One excellent way to do that is to follow Pro Blog Design&#8217;s new tutorial on how to <a href="http://www.problogdesign.com/how-to/automatic-amazon-s3-backups-on-ubuntu-debian/">automatically back up your files and databases to Amazon S3.</a></p>
<p>S3, or Simple Storage Service, is Amazon&#8217;s cheap cloud data storage system. Michael Martin, the author of the tutorial, says that his bill from last month was $2.60. ($0.15 per month per GB for stored, $0.15 per GB transferred.) Using a backup script on your server, you can automatically archive and encrypt your files and MySQL dumps, then send them off to Amazon&#8217;s servers for safekeeping.</p>
<blockquote><p>I should start by saying that while s3 is not a free service, it’s  incredibly inexpensive! My bill <strong>for the last month was $2.60</strong>,  and that was with backing up a lot more than just this site! It’s the  cheapest peace-of-mind ever.</p></blockquote>
<p><a href="http://www.problogdesign.com/how-to/automatic-amazon-s3-backups-on-ubuntu-debian/">Automatic Amazon S3 Backups on Ubuntu/Debian</a> [Pro Blog Design]</p>
]]></content:encoded>
			<wfw:commentRss>https://www.webmaster-source.com/2010/03/15/automatic-amazon-s3-backups-on-ubuntudebian/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>An API for the Web: Learning YQL</title>
		<link>https://www.webmaster-source.com/2010/01/26/an-api-for-the-web-learning-yql/</link>
		<comments>https://www.webmaster-source.com/2010/01/26/an-api-for-the-web-learning-yql/#comments</comments>
		<pubDate>Tue, 26 Jan 2010 11:56:06 +0000</pubDate>
		<dc:creator><![CDATA[Matt]]></dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://www.webmaster-source.com/?p=2985</guid>
		<description><![CDATA[I just read one of the most interesting articles Net.Tuts+ has published in the last few months: An API for the Web: Learning YQL. Web apps and web services multiply like rabbits. They’re all fun to play with (like rabbits) and fun to integrate into other projects (unlike rabbits). But learning a new API every [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>I just read one of the most interesting articles Net.Tuts+ has published in the last few months: <a href="http://net.tutsplus.com/tutorials/other/an-api-for-the-web-learning-yql/">An API for the Web: Learning YQL</a>.</p>
<blockquote><p>Web apps and web services multiply like rabbits. They’re all fun to  play with (like rabbits) and fun to integrate into other projects  (unlike rabbits). But learning a new API every other day isn’t feasible  or fun. And that’s the problem the Yahoo Query Language (YQL) is out to  solve.</p>
<p>Think of YQL as the API for the web, the one API to rule  them all. It’s not a hard one to learn, so let’s get you up to speed  right now!</p></blockquote>
<p>I couldn&#8217;t have said it better myself. YQL is just that: a wrapper for other APIs. It makes it easy to gather data from virtually any API, mash data up if necessary, and bring it into your own application. With generous daily query limits, and no commercial usage restrictions, what&#8217;s not to like?</p>
<p>A basic query to collect tweets from two twitter accounts would look like this:</p>
<pre class="brush: sql; title: ; notranslate">SELECT * FROM twitter.status.timeline.user WHERE id in ('redwall_hp','fantasyfolder')</pre>
<p>Very much like an SQL query, no? And there are &#8220;tables&#8221; to obtain data from many sources, such as Delicious, Netflix, Facebook, Flickr, Github, Last.fm, RSS feeds, etc.. Is there not a table for an API you need to use? You can create one.</p>
<p><a href="http://query.yahooapis.com/v1/public/yql?q=SELECT%20*%20FROM%20twitter.user.profile%20WHERE%20id%20%3D%20%27redwall_hp%27&amp;format=xml&amp;env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys">Result sets</a> can be returned as XML or JSON.</p>
<p>Developer tools like this and the BOSS search API, which is one of the available tables in YQL, are what I believe will keep Yahoo alive in the coming years.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.webmaster-source.com/2010/01/26/an-api-for-the-web-learning-yql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Secure Your WordPress Installation</title>
		<link>https://www.webmaster-source.com/2009/11/18/how-to-secure-your-wordpress-installation/</link>
		<comments>https://www.webmaster-source.com/2009/11/18/how-to-secure-your-wordpress-installation/#comments</comments>
		<pubDate>Wed, 18 Nov 2009 11:12:58 +0000</pubDate>
		<dc:creator><![CDATA[Matt]]></dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://www.webmaster-source.com/?p=2722</guid>
		<description><![CDATA[Digging into WordPress has recently published a new article on securing WordPress. It covers setting up optimal database privileges, adjustments you can make to your wp-config.php file, changing the table prefix, changing the default admin username, and a couple other things. Of course, when it comes to the security of your WordPress site, these techniques [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Digging into WordPress has recently published a new article on securing WordPress. It covers setting up optimal database privileges, adjustments you can make to your wp-config.php file, changing the table prefix, changing the default admin username, and a couple other things.</p>
<blockquote><p>Of course, when it comes to the security of your WordPress site, these techniques are merely the beginning. As you continue in your WordPress travels, you will discover many, many more ways to increase the security of your site. By implementing the methods presented in this article during the setup process, you will be strengthening the security of your site’s foundation, providing yourself a solid platform on which to build.</p></blockquote>
<p>Definitely worth a read if you haven&#8217;t already looked into the techniques.</p>
<p><a href="http://digwp.com/2009/11/how-to-secure-your-new-wordpress-installation/">How to Secure Your New WordPress Installation</a> [Digging into WordPress]</p>
]]></content:encoded>
			<wfw:commentRss>https://www.webmaster-source.com/2009/11/18/how-to-secure-your-wordpress-installation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL Prepared Statements With PHP</title>
		<link>https://www.webmaster-source.com/2009/02/25/mysql-prepared-statements-with-php/</link>
		<comments>https://www.webmaster-source.com/2009/02/25/mysql-prepared-statements-with-php/#comments</comments>
		<pubDate>Wed, 25 Feb 2009 12:40:23 +0000</pubDate>
		<dc:creator><![CDATA[Matt]]></dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.webmaster-source.com/?p=1833</guid>
		<description><![CDATA[You may already be familliar with the problem of MySQL Injection, a common exploit that can cause irreparible damage to a database. You may not be aware of it, but there is an alternative to the &#8220;mysql_*&#8221; function set. The mysqli functions, for &#8220;MySQL Improved&#8221; are used in much the same way as their predecessor, [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>You may already be familliar with the problem of <a href="http://www.webmaster-source.com/2009/01/27/php-tip-prevent-sql-injection/">MySQL Injection</a>, a common exploit that can cause irreparible damage to a database.</p>
<p>You may not be aware of it, but there is an alternative to the &#8220;mysql_*&#8221; function set. The mysqli functions, for &#8220;MySQL Improved&#8221; are used in much the same way as their predecessor, but they have some advantages. One such advantage is &#8220;Prepared Statements,&#8221; a method of preparing a query that separates the data from the syntax.</p>
<p>Prepared Statements are a little harder to use, but they are more secure, and arguably easier to write and maintain.</p>
<p><a href="http://www.mattbango.com/articles/prepared-statements-in-php-and-mysqli">Prepared Statements in PHP and MySQLi</a></p>
<blockquote><p>Instead of grabbing and building the query string using things like $_GET[&#8216;username&#8217;], we have ?&#8217;s instead. These ?&#8217;s separate the SQL logic from the data. The ?&#8217;s are place holders until the next line where we bind our parameters to be the username and password. The rest of the code is pretty much just calling methods which you can read about by following some of the links at the end of the article.</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>https://www.webmaster-source.com/2009/02/25/mysql-prepared-statements-with-php/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PHP Tip: Prevent SQL Injection</title>
		<link>https://www.webmaster-source.com/2009/01/27/php-tip-prevent-sql-injection/</link>
		<comments>https://www.webmaster-source.com/2009/01/27/php-tip-prevent-sql-injection/#comments</comments>
		<pubDate>Tue, 27 Jan 2009 11:41:42 +0000</pubDate>
		<dc:creator><![CDATA[Matt]]></dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[SQL injection]]></category>

		<guid isPermaLink="false">http://www.webmaster-source.com/?p=1764</guid>
		<description><![CDATA[SQL Injection is one of the most common exploits. It&#8217;s a sneaky technique that takes advantage of unsafe database querying practices to gain access to the database. Suppose you have a input form that asks for an email address for a newsletter subscription. The data is passed to the script, which inserts the data with [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>SQL Injection is one of the most common exploits. It&#8217;s a sneaky technique that takes advantage of unsafe database querying practices to gain access to the database.</p>
<p>Suppose you have a input form that asks for an email address for a newsletter subscription. The data is passed to the script, which inserts the data with the following:</p>
<p><code>$input = $_POST['email'];<br />
mysql_query("INSERT INTO emails (email) VALUES('$input')");</code></p>
<p>Looks fine at a glance, doesn&#8217;t it? Well, it would if you&#8217;re new to the horrors of SQL injection. Note that the form field&#8217;s data is passed right along without any validation. That is not good. Some contempt-worthy person could come along and type something like this into the form:<span id="more-1764"></span></p>
<p><code>blah@example.org'); DROP TABLE emails;</code></p>
<p>This would insert a dummy email, then delete the whole database table. Oops.</p>
<p>How can you protect yourself from SQL Injection? The first step is to validate your data. You&#8217;re expecting an email address to be submitted, right? So why don&#8217;t you make sure the submitted data looks like an email address? You could use regular expressions (or something) to make sure the string is a substring followed by a &#8220;@&#8221; followed by another substring, and make sure there aren&#8217;t any characters that wouldn&#8217;t be valid in an email address.</p>
<p>The next step is to use the <a href="http://us3.php.net/mysql_real_escape_string">mysql_real_escape_string()</a> function to remove any escape characters from the string, to make sure there are no unpleasant surprises in the input string. The PHP function reference recommends that you do this any time you query the database with information from a user.</p>
<p style="text-align: center;"><a href="http://xkcd.com/327/"><img style=' display: block; margin-right: auto; margin-left: auto;'  class="aligncenter" title="XKCD Comic" src="http://imgs.xkcd.com/comics/exploits_of_a_mom.png" alt="" width="599" height="185" /></a></p>
<p>SQL Injection is definitey something you need to be aware of. Do some Google-ing and read up on it. The worst that could happen is having no one try to hack the script you spent time securing.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.webmaster-source.com/2009/01/27/php-tip-prevent-sql-injection/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>8 Useful WordPress SQL Hacks</title>
		<link>https://www.webmaster-source.com/2008/12/23/8-useful-wordpress-sql-hacks/</link>
		<comments>https://www.webmaster-source.com/2008/12/23/8-useful-wordpress-sql-hacks/#comments</comments>
		<pubDate>Tue, 23 Dec 2008 11:16:08 +0000</pubDate>
		<dc:creator><![CDATA[Matt]]></dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://www.webmaster-source.com/?p=1623</guid>
		<description><![CDATA[Smashing Magazine has done it again. Their latest post, 8 Useful WordPress SQL Hacks, is a goldmine of useful tricks to streamline your WordPress experience. The tips include Backing up (and restoring) your database Batch deleting post revisions Resetting a lost admin password Updating your database with a new domain, if you ever move to [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Smashing Magazine has done it again. Their latest post, <a href="http://www.smashingmagazine.com/2008/12/18/8-useful-wordpress-sql-hacks/">8 Useful WordPress SQL Hacks</a>, is a goldmine of useful tricks to streamline your WordPress experience.</p>
<p>The tips include</p>
<ul>
<li>Backing up (and restoring) your database</li>
<li>Batch deleting post revisions</li>
<li>Resetting a lost admin password</li>
<li>Updating your database with a new domain, if you ever move to a new one</li>
</ul>
<p>Definitely some knowledge to have your blogger&#8217;s toolbox.</p>
<p>If you really want to master SQL, I&#8217;d recommend reading <a href="http://www.webmaster-source.com/2008/10/08/learning-mysql-book-review/"><em>Learning MySQL</em></a> or similar book.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.webmaster-source.com/2008/12/23/8-useful-wordpress-sql-hacks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Learning MySQL [Book Review]</title>
		<link>https://www.webmaster-source.com/2008/10/08/learning-mysql-book-review/</link>
		<comments>https://www.webmaster-source.com/2008/10/08/learning-mysql-book-review/#comments</comments>
		<pubDate>Wed, 08 Oct 2008 10:06:34 +0000</pubDate>
		<dc:creator><![CDATA[Matt]]></dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[books]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.webmaster-source.com/?p=899</guid>
		<description><![CDATA[Almost anyone who&#8217;s played around with PHP before has run into the subject of databases. MySQL databases are the most common method of storing massive amounts of data to later be sorted through and retrieved for display via script. WordPress stores all of it&#8217;s posts and settings in MySQL tables, forum scripts are powered by [&#8230;]]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.amazon.com/gp/product/0596008643?ie=UTF8&amp;tag=webmasterso0d-20&amp;link_code=as3&amp;camp=211189&amp;creative=373489&amp;creativeASIN=0596008643"><img style=' float: left; padding: 4px; margin: 0 7px 2px 0;'  class="alignleft" title="Learning MySQL" src="http://images.amazon.com/images/P/0596008643.jpg" alt="" width="122" height="160" /></a>Almost anyone who&#8217;s played around with PHP before has run into the subject of databases. MySQL databases are the most common method of storing massive amounts of data to later be sorted through and retrieved for display via script. WordPress stores all of it&#8217;s posts and settings in MySQL tables, forum scripts are powered by databases, sites like Amazon, YouTube, and of course IMDB make extensive use of databases. If you think about it, most modern websites are just pretty user interfaces for databases.</p>
<p>As common as they may be, databases sure are mysterious critters. It look me awhile to grasp the concept of them at first, and even longer for me to pick-up the skills required to make use of them. In addition to knowing a scripting language like PHP or Perl, and how to submit a query to the DB server, you also need to know the SQL language.</p>
<p>I just finished a great book on MySQL. <a href="http://www.amazon.com/gp/product/0596008643?ie=UTF8&amp;tag=webmasterso0d-20&amp;link_code=as3&amp;camp=211189&amp;creative=373489&amp;creativeASIN=0596008643"><em>Learning MySQL</em></a> by Seyed M.M. Tahaghoghi and Hugh Williams is a comprehensive and well-explained book that teaches you from the ground up about MySQL databases and how to work with them. It introduces the concept of a database, walks you through installing the MySQL server software (if you&#8217;re not already running it), explains querying, then moves on to the real meat of the book: Structured Query Language, or SQL. It covers basic SELECTS and INSERTs, JOINS, nested queries, table and column types, and really everything you need to know to get started.</p>
<p>Following chapters cover topics like using PHP or Perl to interact with databases (as opposed to using a MySQL prompt) and securing web applications. There are also sections on planning database structures optimally, optimizing performance.</p>
<p>The book is written in a manner that should make it easy to follow, it&#8217;s full of code examples to try out, and overall is enough to give you a general to intermediate knowledge of MySQL. It also works as a handy reference.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.webmaster-source.com/2008/10/08/learning-mysql-book-review/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/


Served from: www.webmaster-source.com @ 2026-04-29 11:40:47 by W3 Total Cache
-->