<?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>withinweb</title>
	<atom:link href="http://www.withinweb.com/info/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.withinweb.com/info</link>
	<description>Information and support for products of withinweb.com</description>
	<lastBuildDate>Thu, 17 May 2012 14:15:00 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Date Only from SQL using Microsoft SQL Server</title>
		<link>http://www.withinweb.com/info/2012/05/17/date-only-from-sql-using-microsoft-sql-server/</link>
		<comments>http://www.withinweb.com/info/2012/05/17/date-only-from-sql-using-microsoft-sql-server/#comments</comments>
		<pubDate>Thu, 17 May 2012 14:15:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[SQL databases]]></category>

		<guid isPermaLink="false">http://www.withinweb.com/info/?p=685</guid>
		<description><![CDATA[Here is quite a useful function for producing or saving only the date part of the smalldatetime datatype.
This can be useful if you only need to store the date or you need to group some results by date only.
SelectConvert([smalldatetime],floor(Convert([float],getdate(),(0))),(0))
]]></description>
			<content:encoded><![CDATA[<p>Here is quite a useful function for producing or saving only the date part of the smalldatetime datatype.</p>
<p>This can be useful if you only need to store the date or you need to group some results by date only.</p>
<p>SelectConvert([smalldatetime],floor(Convert([float],getdate(),(0))),(0))</p>
]]></content:encoded>
			<wfw:commentRss>http://www.withinweb.com/info/2012/05/17/date-only-from-sql-using-microsoft-sql-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Vote for the digital content type that you are selling</title>
		<link>http://www.withinweb.com/info/2012/05/16/vote-for-the-digital-content-type-that-you-are-selling/</link>
		<comments>http://www.withinweb.com/info/2012/05/16/vote-for-the-digital-content-type-that-you-are-selling/#comments</comments>
		<pubDate>Wed, 16 May 2012 08:06:29 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[OnLine Poll Results]]></category>

		<guid isPermaLink="false">http://www.withinweb.com/info/?p=681</guid>
		<description><![CDATA[Take the survey to tell us what type of digtial content you are selling or about to sell.
This is an on going survey &#8211; we publish the results every month to see if there are any changes in trends.
The survey is located on the right hand side of the page http://www.withinweb.com/phpeseller/index.php
When you make a vote, [...]]]></description>
			<content:encoded><![CDATA[<p>Take the survey to tell us what type of digtial content you are selling or about to sell.</p>
<p>This is an on going survey &#8211; we publish the results every month to see if there are any changes in trends.</p>
<p>The survey is located on the right hand side of the page <a title="sell digital downloads" href="http://www.withinweb.com/phpeseller/index.php">http://www.withinweb.com/phpeseller/index.php</a></p>
<p>When you make a vote, you will be able to see the running totals of figures on the page.</p>
<p>We also publish the results once a month to review any changes.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.withinweb.com/info/2012/05/16/vote-for-the-digital-content-type-that-you-are-selling/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Further PHP try / catch PHP 5</title>
		<link>http://www.withinweb.com/info/2012/05/15/further-php-try-catch-php-5/</link>
		<comments>http://www.withinweb.com/info/2012/05/15/further-php-try-catch-php-5/#comments</comments>
		<pubDate>Tue, 15 May 2012 14:55:52 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[General PHP]]></category>

		<guid isPermaLink="false">http://www.withinweb.com/info/?p=678</guid>
		<description><![CDATA[A try / catch block is meant to catch exceptions.  An exception would be something like divide by zero which causes a program exception and this can be caught.
An error on the other hand is not usually recoverable.  An example of an error would be forgetting to place a ; at the end of a [...]]]></description>
			<content:encoded><![CDATA[<p>A try / catch block is meant to catch exceptions.  An exception would be something like divide by zero which causes a program exception and this can be caught.</p>
<p>An error on the other hand is not usually recoverable.  An example of an error would be forgetting to place a ; at the end of a line or not enclosing a string with &#8221; marks.</p>
<p>In the case of divide by zero, if you use a try / catch block, program execution will continue because you have caught the exception.</p>
<p>Each try must have at least one corresponding catch block.  You can have multiple catch blocks to catch different classes of exceptions.</p>
<p>When an exception is thrown, the code following the statement will not be executed and PHP will then attempt to find the first matching catch block.</p>
<p>The general form of a try / catch block is :</p>
<p>try<br />
{<br />
$a = 1;<br />
$b = 0;<br />
$c = $a / $b;<br />
}<br />
catch (Exception $e)<br />
{<br />
echo($e-&gt;getMessage());<br />
}</p>
<p>Other functions of the exception class are :</p>
<p>getMessage();        // message of exception<br />
getCode();           // code of exception<br />
getFile();           // source filename<br />
getLine();           // source line<br />
getTrace();          // an array of the backtrace()<br />
getPrevious();       // previous exception<br />
getTraceAsString();  // formatted string of trace</p>
<p>You may extend the exception class to create your own custom exceptions and the use them as multiple catch blocks to catch different classes of exception as shown in the following code :</p>
<p>&lt;?php</p>
<p>//Extending the exception class</p>
<p>class WidgetNotFoundException extends Exception {}</p>
<p>function use_widget($widget_name) {<br />
$widget = find_widget($widget_name);</p>
<p>if (!$widget) {<br />
throw new WidgetNotFoundException(t(&#8216;Widget %widget not found.&#8217;, array(&#8216;%widget&#8217; =&gt; $widget_name)));<br />
}<br />
}</p>
<p>//The try / catch block</p>
<p>try {<br />
$widget = &#8216;thingie&#8217;;<br />
$result = use_widget($widget);</p>
<p>// Continue processing the $result.<br />
// If an exception is thrown by use_widget(), this code never gets called.<br />
}<br />
catch (WidgetNotFoundException $e) {<br />
// Error handling specific to the absence of a widget.<br />
}<br />
catch (Exception $e) {<br />
// Generic exception handling if something else gets thrown.<br />
watchdog(&#8216;widget&#8217;, $e-&gt;getMessage(), WATCHDOG_ERROR);<br />
}</p>
<p>?&gt;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.withinweb.com/info/2012/05/15/further-php-try-catch-php-5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple PHP 5 error handling</title>
		<link>http://www.withinweb.com/info/2012/05/14/simple-php-5-error-handling/</link>
		<comments>http://www.withinweb.com/info/2012/05/14/simple-php-5-error-handling/#comments</comments>
		<pubDate>Mon, 14 May 2012 13:13:59 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[General PHP]]></category>

		<guid isPermaLink="false">http://www.withinweb.com/info/?p=672</guid>
		<description><![CDATA[&#60;?php
//create function with an exception
function checkNum($number)
{
if($number&#62;1)
{
throw new Exception(&#8220;Value must be 1 or below&#8221;);
}
return true;
}
//trigger exception in a &#8220;try&#8221; block
try
{
checkNum(2);//If the exception is thrown, this text will not be shownecho &#8216;If you see this, the number is 1 or below&#8217;;}
//catch exception
catch(Exception $e)
{
echo &#8216;Message: &#8216; .$e-&#62;getMessage();
}
?&#62;
]]></description>
			<content:encoded><![CDATA[<p>&lt;?php<br />
//create function with an exception<br />
function checkNum($number)<br />
{<br />
if($number&gt;1)<br />
{<br />
throw new Exception(&#8220;Value must be 1 or below&#8221;);<br />
}<br />
return true;<br />
}</p>
<p>//trigger exception in a &#8220;try&#8221; block<br />
try<br />
{<br />
checkNum(2);//If the exception is thrown, this text will not be shownecho &#8216;If you see this, the number is 1 or below&#8217;;}<br />
//catch exception<br />
catch(Exception $e)<br />
{<br />
echo &#8216;Message: &#8216; .$e-&gt;getMessage();<br />
}<br />
?&gt;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.withinweb.com/info/2012/05/14/simple-php-5-error-handling/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Examples of using PDO objects in PHP</title>
		<link>http://www.withinweb.com/info/2012/05/13/examples-of-using-pdo-objects-in-php/</link>
		<comments>http://www.withinweb.com/info/2012/05/13/examples-of-using-pdo-objects-in-php/#comments</comments>
		<pubDate>Sun, 13 May 2012 21:36:36 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[General PHP]]></category>

		<guid isPermaLink="false">http://www.withinweb.com/info/?p=668</guid>
		<description><![CDATA[&#60;?php
//Example of fetching data from a database using PDO objects
# using the shortcut -&#62;query() method here since there are no variable
# values in the select statement.
try {
$dbhost = &#8220;localhost&#8221;;
$dbname    = &#8220;users&#8221;;
$dbusername = &#8220;root&#8221;;
$dbpass = &#8220;&#8221;;
//Connect to the database
$dbh = new PDO(&#8220;mysql:host=&#8221; . $dbhost . &#8220;;dbname=&#8221; . $dbname, $dbusername, $dbpass);
//the sql query
$sql = &#8220;SELECT * FROM [...]]]></description>
			<content:encoded><![CDATA[<p>&lt;?php</p>
<p>//Example of fetching data from a database using PDO objects</p>
<p># using the shortcut -&gt;query() method here since there are no variable<br />
# values in the select statement.</p>
<p>try {</p>
<p>$dbhost = &#8220;localhost&#8221;;<br />
$dbname    = &#8220;users&#8221;;<br />
$dbusername = &#8220;root&#8221;;<br />
$dbpass = &#8220;&#8221;;</p>
<p>//Connect to the database<br />
$dbh = new PDO(&#8220;mysql:host=&#8221; . $dbhost . &#8220;;dbname=&#8221; . $dbname, $dbusername, $dbpass);</p>
<p>//the sql query<br />
$sql = &#8220;SELECT * FROM users&#8221;;</p>
<p>//statment handle<br />
$sth = $dbh-&gt;query($sql);</p>
<p># setting the fetch mode<br />
$sth-&gt;setFetchMode(PDO::FETCH_ASSOC);</p>
<p>echo(&#8220;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;&lt;br/&gt;&#8221;);<br />
echo(&#8220;An example of a while loop&lt;br/&gt;&#8221;);<br />
while($row = $sth-&gt;fetch()) {<br />
echo( $row["first_name"] . &#8220;&lt;br/&gt;&#8221; );<br />
$table[] = $row;<br />
}</p>
<p>$dbh = null;</p>
<p>}  catch (PDOException $e) {<br />
print &#8220;Error!: &#8221; . $e-&gt;getMessage() . &#8220;&lt;br/&gt;&#8221;;<br />
die();<br />
}</p>
<p>echo(&#8220;&lt;br/&gt;&lt;br/&gt;&#8221;);</p>
<p>echo(&#8220;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;&lt;br/&gt;&#8221;);<br />
echo(&#8220;An example of looping around an array&lt;br/&gt;&#8221;);</p>
<p>if ($table) {    //Check if there are any rows to be displayed<br />
//Retrieve each element of the array<br />
foreach($table as $d_row) {<br />
echo( $d_row["first_name"] . &#8221; &#8221; . $d_row["last_name"] . &#8220;&lt;br/&gt;&#8221; );<br />
}<br />
}</p>
<p>echo(&#8220;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;&lt;br/&gt;&#8221;);<br />
echo(&#8220;An example of printing one element from the array&lt;br/&gt;&#8221;);<br />
echo($table[0]["first_name"]);</p>
<p>?&gt;</p>
<p>&lt;?php</p>
<p>//Example of fetching data from a database using PDO objects</p>
<p>//This uses a prepared statement using named values</p>
<p>try {</p>
<p>$dbhost = &#8220;localhost&#8221;;<br />
$dbname    = &#8220;users&#8221;;<br />
$dbusername = &#8220;root&#8221;;<br />
$dbpass = &#8220;&#8221;;</p>
<p>$first_name = &#8220;%paul%&#8221;;</p>
<p>//Connect to the database<br />
$dbh = new PDO(&#8220;mysql:host=&#8221; . $dbhost . &#8220;;dbname=&#8221; . $dbname, $dbusername, $dbpass);</p>
<p>//the sql query using a named placeholder<br />
$sql = &#8220;SELECT * FROM users WHERE first_name LIKE :first_name &#8220;;</p>
<p>//statment handle<br />
$sth = $dbh-&gt;prepare($sql);</p>
<p>$sth-&gt;execute(array(&#8220;:first_name&#8221; =&gt; $first_name));</p>
<p>$sth-&gt;setFetchMode(PDO::FETCH_ASSOC);</p>
<p>echo(&#8220;&lt;br/&gt;&lt;br/&gt;&#8221;);<br />
echo(&#8220;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;&lt;br/&gt;&#8221;);<br />
echo(&#8220;An example of printing values from a select statement with parameters&lt;br/&gt;&#8221;);</p>
<p>while($row = $sth-&gt;fetch()) {<br />
echo( $row["first_name"] . &#8220;&lt;br/&gt;&#8221; );<br />
$table[] = $row;<br />
}</p>
<p>$dbh = null;</p>
<p>}  catch (PDOException $e) {<br />
print &#8220;Error!: &#8221; . $e-&gt;getMessage() . &#8220;&lt;br/&gt;&#8221;;<br />
die();<br />
}</p>
<p>?&gt;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.withinweb.com/info/2012/05/13/examples-of-using-pdo-objects-in-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Some regular expression matches</title>
		<link>http://www.withinweb.com/info/2012/05/12/some-regular-expression-matches/</link>
		<comments>http://www.withinweb.com/info/2012/05/12/some-regular-expression-matches/#comments</comments>
		<pubDate>Sat, 12 May 2012 09:27:49 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[General PHP]]></category>

		<guid isPermaLink="false">http://www.withinweb.com/info/?p=665</guid>
		<description><![CDATA[Regular Expression     Will match&#8230;
foo     The string &#8220;foo&#8221;
^foo     &#8221;foo&#8221; at the start of a string
foo$     &#8221;foo&#8221; at the end of a string
^foo$     &#8221;foo&#8221; when it is alone on a string
[abc]     a, b, or c
[a-z]     Any lowercase letter
[^A-Z]     Any character that is not a uppercase letter
(gif&#124;jpg)     Matches either [...]]]></description>
			<content:encoded><![CDATA[<p>Regular Expression     Will match&#8230;</p>
<p>foo     The string &#8220;foo&#8221;<br />
^foo     &#8221;foo&#8221; at the start of a string<br />
foo$     &#8221;foo&#8221; at the end of a string<br />
^foo$     &#8221;foo&#8221; when it is alone on a string<br />
[abc]     a, b, or c<br />
[a-z]     Any lowercase letter<br />
[^A-Z]     Any character that is not a uppercase letter<br />
(gif|jpg)     Matches either &#8220;gif&#8221; or &#8220;jpeg&#8221;<br />
[a-z]+     One or more lowercase letters<br />
[0-9\.\-]     ?ny number, dot, or minus sign<br />
^[a-zA-Z0-9_]{1,}$     Any word of at least one letter, number or _<br />
([wx])([yz])     wy, wz, xy, or xz<br />
[^A-Za-z0-9]     Any symbol (not a number or a letter)<br />
([A-Z]{3}|[0-9]{4})     Matches three letters or four numbers</p>
]]></content:encoded>
			<wfw:commentRss>http://www.withinweb.com/info/2012/05/12/some-regular-expression-matches/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Possible way of dealing with inserting quote marks into a database</title>
		<link>http://www.withinweb.com/info/2012/05/11/possible-way-of-dealing-with-inserting-quote-marks-into-a-database/</link>
		<comments>http://www.withinweb.com/info/2012/05/11/possible-way-of-dealing-with-inserting-quote-marks-into-a-database/#comments</comments>
		<pubDate>Fri, 11 May 2012 11:23:17 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[General PHP]]></category>
		<category><![CDATA[Security Issues]]></category>

		<guid isPermaLink="false">http://www.withinweb.com/info/?p=660</guid>
		<description><![CDATA[This is another possible way of dealing with quote marks for inserting data into a database :
if (!get_magic_quotes_gpc()) {
$item_name = addslashes($_POST['txtItem_Name']);
}
else
{
$item_name = $_POST['txtItem_Name'];
}
Dealing with quote marks for inserting data into a database
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;
if (!get_magic_quotes_gpc()) {
$item_name = addslashes($_POST['txtItem_Name']);
}
else
{
$item_name = $_POST['txtItem_Name'];
}

]]></description>
			<content:encoded><![CDATA[<p>This is another possible way of dealing with quote marks for inserting data into a database :</p>
<p>if (!get_magic_quotes_gpc()) {<br />
$item_name = addslashes($_POST['txtItem_Name']);<br />
}<br />
else<br />
{<br />
$item_name = $_POST['txtItem_Name'];<br />
}</p>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;">Dealing with quote marks for inserting data into a database<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>if (!get_magic_quotes_gpc()) {<br />
$item_name = addslashes($_POST['txtItem_Name']);<br />
}<br />
else<br />
{<br />
$item_name = $_POST['txtItem_Name'];<br />
}</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.withinweb.com/info/2012/05/11/possible-way-of-dealing-with-inserting-quote-marks-into-a-database/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Regular Expression     Will match&#8230;</title>
		<link>http://www.withinweb.com/info/2012/05/10/regular-expression-will-match/</link>
		<comments>http://www.withinweb.com/info/2012/05/10/regular-expression-will-match/#comments</comments>
		<pubDate>Thu, 10 May 2012 20:02:41 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[General PHP]]></category>

		<guid isPermaLink="false">http://www.withinweb.com/info/?p=656</guid>
		<description><![CDATA[Regular Expression     Will match&#8230;
foo                                The string &#8220;foo&#8221;
^foo                            &#8220;foo&#8221; at the start of a string
foo$                            &#8220;foo&#8221; at the end of a string
^foo$                         &#8220;foo&#8221; when it is alone on a string
[abc]                           a, b, or c
[a-z]                           Any [...]]]></description>
			<content:encoded><![CDATA[<p>Regular Expression     Will match&#8230;</p>
<p>foo                                The string &#8220;foo&#8221;<br />
^foo                            &#8220;foo&#8221; at the start of a string<br />
foo$                            &#8220;foo&#8221; at the end of a string<br />
^foo$                         &#8220;foo&#8221; when it is alone on a string<br />
[abc]                           a, b, or c<br />
[a-z]                           Any lowercase letter<br />
[^A-Z]                      Any character that is not a uppercase letter<br />
(gif|jpg)                   Matches either &#8220;gif&#8221; or &#8220;jpeg&#8221;<br />
[a-z]+                       One or more lowercase letters<br />
[0-9\.\-]                  any number, dot, or minus sign<br />
^[a-zA-Z0-9_]{1,}$      Any word of at least one letter, number or _<br />
([wx])([yz])                    wy, wz, xy, or xz<br />
[^A-Za-z0-9]                 Any symbol (not a number or a letter)<br />
([A-Z]{3}|[0-9]{4})     Matches three letters or four numbers</p>
]]></content:encoded>
			<wfw:commentRss>http://www.withinweb.com/info/2012/05/10/regular-expression-will-match/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Use regular expressions to validate PHP inputs</title>
		<link>http://www.withinweb.com/info/2012/05/10/use-regular-expressions-to-validate-php-inputs/</link>
		<comments>http://www.withinweb.com/info/2012/05/10/use-regular-expressions-to-validate-php-inputs/#comments</comments>
		<pubDate>Thu, 10 May 2012 09:17:16 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Security Issues]]></category>

		<guid isPermaLink="false">http://www.withinweb.com/info/?p=651</guid>
		<description><![CDATA[To help counter SQL injections you need to make sure that entered values use minimum character types as possible.  So you restrict usernames to just a-z and 0-9 characters.
To test for these, use something like :
//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;
/**
* Purpose : Check input for paticular characters
* Only allow a &#8211; z, A &#8211; Z , 0-9
* returns true [...]]]></description>
			<content:encoded><![CDATA[<p>To help counter SQL injections you need to make sure that entered values use minimum character types as possible.  So you restrict usernames to just a-z and 0-9 characters.</p>
<p>To test for these, use something like :</p>
<p>//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
/**<br />
* Purpose : Check input for paticular characters<br />
* Only allow a &#8211; z, A &#8211; Z , 0-9<br />
* returns true if a match was found, false if no match was found<br />
* @return boolean<br />
*/<br />
function is_valid_input($words) {</p>
<p>if ( preg_match( &#8220;/[^0-9a-zA-Z]/&#8221;, $words, $array ) )<br />
return false;        //invalid characters<br />
else<br />
return true;        //valid characters</p>
<p>}</p>
]]></content:encoded>
			<wfw:commentRss>http://www.withinweb.com/info/2012/05/10/use-regular-expressions-to-validate-php-inputs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ways to counter SQL Injection</title>
		<link>http://www.withinweb.com/info/2012/05/09/ways-to-counter-sql-injection-2/</link>
		<comments>http://www.withinweb.com/info/2012/05/09/ways-to-counter-sql-injection-2/#comments</comments>
		<pubDate>Wed, 09 May 2012 08:31:58 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[SQL databases]]></category>
		<category><![CDATA[Security Issues]]></category>

		<guid isPermaLink="false">http://www.withinweb.com/info/?p=648</guid>
		<description><![CDATA[Database Permissions
Set the permissions on the database username / password as tightly as possible.  If you are displaying data, there is no need for the user to have insert or update permissions into the database.  One solution is to have two usernames / passwords.  One would have select permissions, and would be used only for [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Database Permissions</strong></p>
<p>Set the permissions on the database username / password as tightly as possible.  If you are displaying data, there is no need for the user to have insert or update permissions into the database.  One solution is to have two usernames / passwords.  One would have select permissions, and would be used only for display.  The other would have select, insert and update permissions used only for forms that require data to be stored in the database.</p>
<p><strong>Test all data input</strong></p>
<p>All form data and all url query strings should be tested.</p>
<p>For example, if you are passing data using a query string any record id&#8217;s are usually integer, so test that they are actually integer values with a function such as is_numeric in PHP.</p>
<p><strong>Use correct data types and data sizes in the database</strong></p>
<p>This means that if you have a colunn which is a persons name, the data type size for that column only needs to be 40 characters. There is no need to have a data size any larger than required.<br />
<strong>Convert text to html</strong></p>
<p>Before storing text in a database, convert it into html.  This will change inputs such as the Javascript &lt;script&gt; to its html equilivant which cannot be executed on a web page.</p>
<p>Filter out any characters that may cause issues. and are not required.</p>
<p><strong>Use parameterized queries</strong></p>
<p>If you use parametized queries for connection to the database you eliminate string concatenation.  You should always use parametized queries rather than constucting the sql.</p>
<p><strong>Check characters particlarly with username / password</strong></p>
<p>If an entry is a username, it normally does not require any other characters other than a to z and 0 to 9 and it only needs to be say, 8 characters long.</p>
<p><strong>In php, always use the mysql_real_escape_string</strong></p>
<p>http://uk3.php.net/mysql_real_escape_string</p>
<p><strong>SQL Injection pdf</strong></p>
<p>http://dev.mysql.com/tech-resources/articles/guide-to-php-security-ch3.pdf</p>
<p><strong>Description of paramised queries and slq injection in dot.net</strong></p>
<p>http://msdn.microsoft.com/en-us/library/ms998271.aspx</p>
<p><strong>Description of paramised queries and slq injection for php</strong></p>
<p>http://stackoverflow.com/questions/60174/best-way-to-stop-sql-injection-in-php</p>
]]></content:encoded>
			<wfw:commentRss>http://www.withinweb.com/info/2012/05/09/ways-to-counter-sql-injection-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

