<?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: SQL Injection: How To Prevent Security Flaws In PHP / MySQL</title>
	<atom:link href="http://www.learnphponline.com/security/sql-injection-prevention-mysql-php/feed" rel="self" type="application/rss+xml" />
	<link>http://www.learnphponline.com/security/sql-injection-prevention-mysql-php</link>
	<description>Learn PHP Online</description>
	<lastBuildDate>Fri, 03 Sep 2010 17:39:36 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: Haq</title>
		<link>http://www.learnphponline.com/security/sql-injection-prevention-mysql-php/comment-page-1#comment-3083</link>
		<dc:creator>Haq</dc:creator>
		<pubDate>Tue, 17 Aug 2010 19:57:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.learnphponline.com/?p=37#comment-3083</guid>
		<description>Very good info to be shared with, I was wondering how to protect my website from sql injection. Now I have learned the real use of mysql_real_escape_string usage. Thank you very much.

:)</description>
		<content:encoded><![CDATA[<p>Very good info to be shared with, I was wondering how to protect my website from sql injection. Now I have learned the real use of mysql_real_escape_string usage. Thank you very much.</p>
<p> <img src='http://www.learnphponline.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: FYI</title>
		<link>http://www.learnphponline.com/security/sql-injection-prevention-mysql-php/comment-page-1#comment-2852</link>
		<dc:creator>FYI</dc:creator>
		<pubDate>Mon, 02 Aug 2010 02:29:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.learnphponline.com/?p=37#comment-2852</guid>
		<description>Hey people i found something thats helpful for get values
you should also put a post if possible so hackers cant hack those</description>
		<content:encoded><![CDATA[<p>Hey people i found something thats helpful for get values<br />
you should also put a post if possible so hackers cant hack those</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hydronly</title>
		<link>http://www.learnphponline.com/security/sql-injection-prevention-mysql-php/comment-page-1#comment-2456</link>
		<dc:creator>Hydronly</dc:creator>
		<pubDate>Sat, 03 Jul 2010 15:05:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.learnphponline.com/?p=37#comment-2456</guid>
		<description>Thank you very much for your explanation. It helped me out a lot.</description>
		<content:encoded><![CDATA[<p>Thank you very much for your explanation. It helped me out a lot.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pheesh</title>
		<link>http://www.learnphponline.com/security/sql-injection-prevention-mysql-php/comment-page-1#comment-2316</link>
		<dc:creator>Pheesh</dc:creator>
		<pubDate>Tue, 22 Jun 2010 05:08:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.learnphponline.com/?p=37#comment-2316</guid>
		<description>to prevent sql injection from url you would do the same thing as for POST,just do it for GET when you&#039;re getting the data from the url.
  //This stops SQL Injection in POST vars 
  foreach ($_POST as $key =&gt; $value) { 
    $_POST[$key] = mysql_real_escape_string($value); 
  } 

  //This stops SQL Injection in GET vars 
  foreach ($_GET as $key =&gt; $value) { 
    $_GET[$key] = mysql_real_escape_string($value); 
  }</description>
		<content:encoded><![CDATA[<p>to prevent sql injection from url you would do the same thing as for POST,just do it for GET when you&#8217;re getting the data from the url.<br />
  //This stops SQL Injection in POST vars<br />
  foreach ($_POST as $key =&gt; $value) {<br />
    $_POST[$key] = mysql_real_escape_string($value);<br />
  } </p>
<p>  //This stops SQL Injection in GET vars<br />
  foreach ($_GET as $key =&gt; $value) {<br />
    $_GET[$key] = mysql_real_escape_string($value);<br />
  }</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dyl</title>
		<link>http://www.learnphponline.com/security/sql-injection-prevention-mysql-php/comment-page-1#comment-2255</link>
		<dc:creator>Dyl</dc:creator>
		<pubDate>Tue, 15 Jun 2010 21:35:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.learnphponline.com/?p=37#comment-2255</guid>
		<description>Yeah, I would REALLY want to know how to prevent the SQL Injection from the URL.</description>
		<content:encoded><![CDATA[<p>Yeah, I would REALLY want to know how to prevent the SQL Injection from the URL.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chantal</title>
		<link>http://www.learnphponline.com/security/sql-injection-prevention-mysql-php/comment-page-1#comment-2196</link>
		<dc:creator>Chantal</dc:creator>
		<pubDate>Mon, 07 Jun 2010 15:33:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.learnphponline.com/?p=37#comment-2196</guid>
		<description>Thanks for the great tutorial. I really appreciated the plain language and simplistic, easy-to-follow examples.</description>
		<content:encoded><![CDATA[<p>Thanks for the great tutorial. I really appreciated the plain language and simplistic, easy-to-follow examples.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Robin</title>
		<link>http://www.learnphponline.com/security/sql-injection-prevention-mysql-php/comment-page-1#comment-1892</link>
		<dc:creator>Robin</dc:creator>
		<pubDate>Fri, 09 Apr 2010 20:31:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.learnphponline.com/?p=37#comment-1892</guid>
		<description>For everyone who&#039;s interested in preventing SQL injection from user input, you might want to check our newly released opensource library ValidForm Builder.

Some of the key features are:
- Fully CSS and webstandards based forms (no tables)
- Prevent SQL Injection using both clientside and serverside validation
- Check http://www.validformbuilder.org/ for more information, tutorials, complete API reference guide and ofcourse the source download!

This is no commercial; it&#039;s a free to use opensource library for creating webforms.</description>
		<content:encoded><![CDATA[<p>For everyone who&#8217;s interested in preventing SQL injection from user input, you might want to check our newly released opensource library ValidForm Builder.</p>
<p>Some of the key features are:<br />
- Fully CSS and webstandards based forms (no tables)<br />
- Prevent SQL Injection using both clientside and serverside validation<br />
- Check <a href="http://www.validformbuilder.org/" rel="nofollow">http://www.validformbuilder.org/</a> for more information, tutorials, complete API reference guide and ofcourse the source download!</p>
<p>This is no commercial; it&#8217;s a free to use opensource library for creating webforms.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rich</title>
		<link>http://www.learnphponline.com/security/sql-injection-prevention-mysql-php/comment-page-1#comment-1851</link>
		<dc:creator>Rich</dc:creator>
		<pubDate>Tue, 30 Mar 2010 02:33:11 +0000</pubDate>
		<guid isPermaLink="false">http://www.learnphponline.com/?p=37#comment-1851</guid>
		<description>Great post!  I was just wondering, though: how does mysql_real_escape_string protect you against ;DROP TABLE user; #?  You can limit to what users can put into text fields, but doesn&#039;t do any good if your script uses &#039;get&#039; and a hacker can just put it into the url.  I think what I can do with my script is to get rid of spaces all together when validating user input, since users should not use spaces in my case, anyways ;p</description>
		<content:encoded><![CDATA[<p>Great post!  I was just wondering, though: how does mysql_real_escape_string protect you against ;DROP TABLE user; #?  You can limit to what users can put into text fields, but doesn&#8217;t do any good if your script uses &#8216;get&#8217; and a hacker can just put it into the url.  I think what I can do with my script is to get rid of spaces all together when validating user input, since users should not use spaces in my case, anyways ;p</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: hacker</title>
		<link>http://www.learnphponline.com/security/sql-injection-prevention-mysql-php/comment-page-1#comment-1823</link>
		<dc:creator>hacker</dc:creator>
		<pubDate>Mon, 22 Mar 2010 19:42:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.learnphponline.com/?p=37#comment-1823</guid>
		<description>you can do it that way too
$username=mysql_real_escape_string($_POST[&#039;user&#039;]);
$SQL = &quot;SELECT * FROM users WHERE username=&#039;$username&#039; LIMIT 1&quot;);
it is safer that way</description>
		<content:encoded><![CDATA[<p>you can do it that way too<br />
$username=mysql_real_escape_string($_POST['user']);<br />
$SQL = &#8220;SELECT * FROM users WHERE username=&#8217;$username&#8217; LIMIT 1&#8243;);<br />
it is safer that way</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rhett Phillips</title>
		<link>http://www.learnphponline.com/security/sql-injection-prevention-mysql-php/comment-page-1#comment-1822</link>
		<dc:creator>Rhett Phillips</dc:creator>
		<pubDate>Mon, 22 Mar 2010 18:50:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.learnphponline.com/?p=37#comment-1822</guid>
		<description>Going off the last comment, here&#039;s a quick method to cover all your bases in a pinch.

function me($v){return mysql_real_escape_string($v);}
if($_POST){foreach($_POST as $posts){$posts=me($posts);}}
if($_GET){foreach($_GET as $gets){$gets=me($gets);}}

Put these 3 lines on the same include page as your database class or wherever you connect to a mysql db, you&#039;re all set. Remember three things:
(1) This is not the most efficient method cause it has to work those strings every single time all the time.
(2) The escaping only works if you are connected to mysql.
(3) I only created a separate me() function for brevity and reuse on whatever.</description>
		<content:encoded><![CDATA[<p>Going off the last comment, here&#8217;s a quick method to cover all your bases in a pinch.</p>
<p>function me($v){return mysql_real_escape_string($v);}<br />
if($_POST){foreach($_POST as $posts){$posts=me($posts);}}<br />
if($_GET){foreach($_GET as $gets){$gets=me($gets);}}</p>
<p>Put these 3 lines on the same include page as your database class or wherever you connect to a mysql db, you&#8217;re all set. Remember three things:<br />
(1) This is not the most efficient method cause it has to work those strings every single time all the time.<br />
(2) The escaping only works if you are connected to mysql.<br />
(3) I only created a separate me() function for brevity and reuse on whatever.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
