<?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>Rui Miguel Feio &#187; PHP</title>
	<atom:link href="http://www.ruifeio.com/category/web-development/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ruifeio.com</link>
	<description>Sharing knowledge with the world</description>
	<lastBuildDate>Sat, 04 Sep 2010 17:29:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Notice:  Undefined index: message in /home/example.php on line 9</title>
		<link>http://www.ruifeio.com/2009/09/28/notice-undefined-index-message-in-hometestexample-php-on-line-3/</link>
		<comments>http://www.ruifeio.com/2009/09/28/notice-undefined-index-message-in-hometestexample-php-on-line-3/#comments</comments>
		<pubDate>Mon, 28 Sep 2009 20:25:46 +0000</pubDate>
		<dc:creator>Rui Miguel Feio</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.ruifeio.com/?p=390</guid>
		<description><![CDATA[If  you&#8217;re getting this message on PHP this is due to your PHP error reporting settings not being set correctly. You can suppress the Notice warnings by changing the error reporting settings on PHP.ini (permanent change) or adding an extra line to your PHP script. Changing PHP.ini: Changing your PHP.ini makes the change permanent and [...]]]></description>
			<content:encoded><![CDATA[<p>If  you&#8217;re getting this message on PHP this is due to your PHP error reporting settings not being set correctly.</p>
<p>You can suppress the Notice warnings by changing the error reporting settings on PHP.ini (permanent change) or adding an extra line to your PHP script.</p>
<p><strong>Changing PHP.ini:</strong></p>
<p>Changing your PHP.ini makes the change permanent and available to every PHP script you run.</p>
<ol>
<li>Edit your PHP.ini file</li>
<li>Locate the line that has <em>error_reporting</em> without the <em>;</em> in the beginning (ex: <em>error_reporting = E_ALL</em>)</li>
<li>Change this to <em>error_reporting = E_ALL &amp; ~E_NOTICE</em></li>
<li>Save PHP.ini</li>
</ol>
<p><strong>Adding line to your script:</strong></p>
<p>Just add the following line to the beginning of your script:</p>
<p><em>error_reporting (E_ALL ^ E_NOTICE);</em></p>
<p><strong>Explanation:</strong></p>
<p><em>error_reporting = E_ALL &amp; ~E_NOTICE</em> tells the system to show all errors and warnings except those for notices.</p>
<div class="fullcircle-social-links" style="display: block;"></div><div style="clear: both;"></div>
<div class="sociable">

<ul>
	<li class="sociablefirst"><a rel="nofollow"  target="_blank" href="mailto:?subject=Notice%3A%20%20Undefined%20index%3A%20message%20in%20%2Fhome%2Fexample.php%20on%20line%209&amp;body=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F09%2F28%2Fnotice-undefined-index-message-in-hometestexample-php-on-line-3%2F" title="email"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="javascript:AddToFavorites();" title="Add to favorites"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/addtofavorites.png" title="Add to favorites" alt="Add to favorites" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F09%2F28%2Fnotice-undefined-index-message-in-hometestexample-php-on-line-3%2F&amp;t=Notice%3A%20%20Undefined%20index%3A%20message%20in%20%2Fhome%2Fexample.php%20on%20line%209" title="Facebook"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://twitter.com/home?status=Notice%3A%20%20Undefined%20index%3A%20message%20in%20%2Fhome%2Fexample.php%20on%20line%209%20-%20http%3A%2F%2Fwww.ruifeio.com%2F2009%2F09%2F28%2Fnotice-undefined-index-message-in-hometestexample-php-on-line-3%2F" title="Twitter"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F09%2F28%2Fnotice-undefined-index-message-in-hometestexample-php-on-line-3%2F&amp;t=Notice%3A%20%20Undefined%20index%3A%20message%20in%20%2Fhome%2Fexample.php%20on%20line%209" title="MySpace"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F09%2F28%2Fnotice-undefined-index-message-in-hometestexample-php-on-line-3%2F&amp;title=Notice%3A%20%20Undefined%20index%3A%20message%20in%20%2Fhome%2Fexample.php%20on%20line%209&amp;notes=If%C2%A0%20you%27re%20getting%20this%20message%20on%20PHP%20this%20is%20due%20to%20your%20PHP%20error%20reporting%20settings%20not%20being%20set%20correctly.%0D%0A%0D%0AYou%20can%20suppress%20the%20Notice%20warnings%20by%20changing%20the%20error%20reporting%20settings%20on%20PHP.ini%20%28permanent%20change%29%20or%20adding%20an%20extra%20line%20t" title="del.icio.us"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F09%2F28%2Fnotice-undefined-index-message-in-hometestexample-php-on-line-3%2F&amp;title=Notice%3A%20%20Undefined%20index%3A%20message%20in%20%2Fhome%2Fexample.php%20on%20line%209&amp;source=Rui+Miguel+Feio+Sharing+knowledge+with+the+world&amp;summary=If%C2%A0%20you%27re%20getting%20this%20message%20on%20PHP%20this%20is%20due%20to%20your%20PHP%20error%20reporting%20settings%20not%20being%20set%20correctly.%0D%0A%0D%0AYou%20can%20suppress%20the%20Notice%20warnings%20by%20changing%20the%20error%20reporting%20settings%20on%20PHP.ini%20%28permanent%20change%29%20or%20adding%20an%20extra%20line%20t" title="LinkedIn"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F09%2F28%2Fnotice-undefined-index-message-in-hometestexample-php-on-line-3%2F&amp;title=Notice%3A%20%20Undefined%20index%3A%20message%20in%20%2Fhome%2Fexample.php%20on%20line%209&amp;bodytext=If%C2%A0%20you%27re%20getting%20this%20message%20on%20PHP%20this%20is%20due%20to%20your%20PHP%20error%20reporting%20settings%20not%20being%20set%20correctly.%0D%0A%0D%0AYou%20can%20suppress%20the%20Notice%20warnings%20by%20changing%20the%20error%20reporting%20settings%20on%20PHP.ini%20%28permanent%20change%29%20or%20adding%20an%20extra%20line%20t" title="Digg"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F09%2F28%2Fnotice-undefined-index-message-in-hometestexample-php-on-line-3%2F&amp;title=Notice%3A%20%20Undefined%20index%3A%20message%20in%20%2Fhome%2Fexample.php%20on%20line%209" title="StumbleUpon"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F09%2F28%2Fnotice-undefined-index-message-in-hometestexample-php-on-line-3%2F&amp;title=Notice%3A%20%20Undefined%20index%3A%20message%20in%20%2Fhome%2Fexample.php%20on%20line%209&amp;annotation=If%C2%A0%20you%27re%20getting%20this%20message%20on%20PHP%20this%20is%20due%20to%20your%20PHP%20error%20reporting%20settings%20not%20being%20set%20correctly.%0D%0A%0D%0AYou%20can%20suppress%20the%20Notice%20warnings%20by%20changing%20the%20error%20reporting%20settings%20on%20PHP.ini%20%28permanent%20change%29%20or%20adding%20an%20extra%20line%20t" title="Google Bookmarks"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://buzz.yahoo.com/submit/?submitUrl=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F09%2F28%2Fnotice-undefined-index-message-in-hometestexample-php-on-line-3%2F&amp;submitHeadline=Notice%3A%20%20Undefined%20index%3A%20message%20in%20%2Fhome%2Fexample.php%20on%20line%209&amp;submitSummary=If%C2%A0%20you%27re%20getting%20this%20message%20on%20PHP%20this%20is%20due%20to%20your%20PHP%20error%20reporting%20settings%20not%20being%20set%20correctly.%0D%0A%0D%0AYou%20can%20suppress%20the%20Notice%20warnings%20by%20changing%20the%20error%20reporting%20settings%20on%20PHP.ini%20%28permanent%20change%29%20or%20adding%20an%20extra%20line%20t&amp;submitCategory=science&amp;submitAssetType=text" title="Yahoo! Buzz"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/yahoobuzz.png" title="Yahoo! Buzz" alt="Yahoo! Buzz" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  target="_blank" href="http://www.indianpad.com/submit.php?url=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F09%2F28%2Fnotice-undefined-index-message-in-hometestexample-php-on-line-3%2F" title="IndianPad"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/indianpad.png" title="IndianPad" alt="IndianPad" class="sociable-hovers" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.ruifeio.com/2009/09/28/notice-undefined-index-message-in-hometestexample-php-on-line-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Backup and Restore a web site in CPANEL</title>
		<link>http://www.ruifeio.com/2009/08/16/backup-and-restore-a-web-site-in-cpanel/</link>
		<comments>http://www.ruifeio.com/2009/08/16/backup-and-restore-a-web-site-in-cpanel/#comments</comments>
		<pubDate>Sun, 16 Aug 2009 20:18:46 +0000</pubDate>
		<dc:creator>Rui Miguel Feio</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.ruifeio.com/?p=246</guid>
		<description><![CDATA[It&#8217;s a good practice to make backups prior to submit any changes to your site. Time and again people skip the backup to find themselves with problems and not having an easy and quick way to undo their changes. This may not seem a big problem, but if the changes were done to the web [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s a good practice to make backups prior to submit any changes to your site.</p>
<p>Time and again people skip the backup to find themselves with problems and not having an easy and quick way to undo their changes. This may not seem a big problem, but if the changes were done to the web site of your business and now the web site is not working probably, this means you&#8217;re losing money!</p>
<p>Backing up a site is easy and even more if your web server uses CPANEL.</p>
<p><strong>Consider the following steps to BACKUP your site:</strong></p>
<ul>
<li>To Backup the files of your site:
<ol>
<li>On <em>CPANEL </em>select option <em>Backups</em></li>
<li>Under <em>Home Directory</em> select option <em>Download a home directory Backup</em></li>
<li>Select <em>Save File</em></li>
</ol>
</li>
<li>To Backup the Databases of your site:
<ol>
<li>On <em>CPANEL </em>select option Backups</li>
<li>Under <span><em>Download a MySQL Database Backup </em>select the Database you wish to Backup</span></li>
<li><span>Select <em>Save File</em></span></li>
<li><span>Repeat Steps 2 and 3 for any other Database you wish to backup</span></li>
</ol>
</li>
</ul>
<p><strong>Consider the following steps to RESTORE your site:</strong></p>
<ul>
<li>To Restore the files of your site:
<ol>
<li>On <em>CPANEL </em>select option <em>Backups</em></li>
<li>Under <em><span>Restore a Home Directory Backup </span></em><span>select <em>Browse </em>and locate the backup you want to restore from<br />
</span></li>
<li>Select <em>Upload</em></li>
</ol>
</li>
<li>To Restore the Databases of your site:
<ol>
<li>On <em>CPANEL </em>select option Backups</li>
<li>Under <em><span>Restore a MySQL Database</span></em><span><em> </em>select <em>Browse </em>and locate the backup you want to restore from.<br />
</span></li>
<li><span>Select <em>Upload</em></span></li>
<li><span>Repeat Steps 2 and 3 for any other Database you wish to restore</span></li>
</ol>
</li>
</ul>
<div class="fullcircle-social-links" style="display: block;"></div><div style="clear: both;"></div>
<div class="sociable">

<ul>
	<li class="sociablefirst"><a rel="nofollow"  target="_blank" href="mailto:?subject=Backup%20and%20Restore%20a%20web%20site%20in%20CPANEL&amp;body=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F08%2F16%2Fbackup-and-restore-a-web-site-in-cpanel%2F" title="email"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="javascript:AddToFavorites();" title="Add to favorites"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/addtofavorites.png" title="Add to favorites" alt="Add to favorites" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F08%2F16%2Fbackup-and-restore-a-web-site-in-cpanel%2F&amp;t=Backup%20and%20Restore%20a%20web%20site%20in%20CPANEL" title="Facebook"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://twitter.com/home?status=Backup%20and%20Restore%20a%20web%20site%20in%20CPANEL%20-%20http%3A%2F%2Fwww.ruifeio.com%2F2009%2F08%2F16%2Fbackup-and-restore-a-web-site-in-cpanel%2F" title="Twitter"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F08%2F16%2Fbackup-and-restore-a-web-site-in-cpanel%2F&amp;t=Backup%20and%20Restore%20a%20web%20site%20in%20CPANEL" title="MySpace"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F08%2F16%2Fbackup-and-restore-a-web-site-in-cpanel%2F&amp;title=Backup%20and%20Restore%20a%20web%20site%20in%20CPANEL&amp;notes=It%27s%20a%20good%20practice%20to%20make%20backups%20prior%20to%20submit%20any%20changes%20to%20your%20site.%0D%0A%0D%0ATime%20and%20again%20people%20skip%20the%20backup%20to%20find%20themselves%20with%20problems%20and%20not%20having%20an%20easy%20and%20quick%20way%20to%20undo%20their%20changes.%20This%20may%20not%20seem%20a%20big%20problem%2C%20but%20" title="del.icio.us"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F08%2F16%2Fbackup-and-restore-a-web-site-in-cpanel%2F&amp;title=Backup%20and%20Restore%20a%20web%20site%20in%20CPANEL&amp;source=Rui+Miguel+Feio+Sharing+knowledge+with+the+world&amp;summary=It%27s%20a%20good%20practice%20to%20make%20backups%20prior%20to%20submit%20any%20changes%20to%20your%20site.%0D%0A%0D%0ATime%20and%20again%20people%20skip%20the%20backup%20to%20find%20themselves%20with%20problems%20and%20not%20having%20an%20easy%20and%20quick%20way%20to%20undo%20their%20changes.%20This%20may%20not%20seem%20a%20big%20problem%2C%20but%20" title="LinkedIn"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F08%2F16%2Fbackup-and-restore-a-web-site-in-cpanel%2F&amp;title=Backup%20and%20Restore%20a%20web%20site%20in%20CPANEL&amp;bodytext=It%27s%20a%20good%20practice%20to%20make%20backups%20prior%20to%20submit%20any%20changes%20to%20your%20site.%0D%0A%0D%0ATime%20and%20again%20people%20skip%20the%20backup%20to%20find%20themselves%20with%20problems%20and%20not%20having%20an%20easy%20and%20quick%20way%20to%20undo%20their%20changes.%20This%20may%20not%20seem%20a%20big%20problem%2C%20but%20" title="Digg"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F08%2F16%2Fbackup-and-restore-a-web-site-in-cpanel%2F&amp;title=Backup%20and%20Restore%20a%20web%20site%20in%20CPANEL" title="StumbleUpon"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F08%2F16%2Fbackup-and-restore-a-web-site-in-cpanel%2F&amp;title=Backup%20and%20Restore%20a%20web%20site%20in%20CPANEL&amp;annotation=It%27s%20a%20good%20practice%20to%20make%20backups%20prior%20to%20submit%20any%20changes%20to%20your%20site.%0D%0A%0D%0ATime%20and%20again%20people%20skip%20the%20backup%20to%20find%20themselves%20with%20problems%20and%20not%20having%20an%20easy%20and%20quick%20way%20to%20undo%20their%20changes.%20This%20may%20not%20seem%20a%20big%20problem%2C%20but%20" title="Google Bookmarks"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://buzz.yahoo.com/submit/?submitUrl=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F08%2F16%2Fbackup-and-restore-a-web-site-in-cpanel%2F&amp;submitHeadline=Backup%20and%20Restore%20a%20web%20site%20in%20CPANEL&amp;submitSummary=It%27s%20a%20good%20practice%20to%20make%20backups%20prior%20to%20submit%20any%20changes%20to%20your%20site.%0D%0A%0D%0ATime%20and%20again%20people%20skip%20the%20backup%20to%20find%20themselves%20with%20problems%20and%20not%20having%20an%20easy%20and%20quick%20way%20to%20undo%20their%20changes.%20This%20may%20not%20seem%20a%20big%20problem%2C%20but%20&amp;submitCategory=science&amp;submitAssetType=text" title="Yahoo! Buzz"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/yahoobuzz.png" title="Yahoo! Buzz" alt="Yahoo! Buzz" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  target="_blank" href="http://www.indianpad.com/submit.php?url=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F08%2F16%2Fbackup-and-restore-a-web-site-in-cpanel%2F" title="IndianPad"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/indianpad.png" title="IndianPad" alt="IndianPad" class="sociable-hovers" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.ruifeio.com/2009/08/16/backup-and-restore-a-web-site-in-cpanel/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to validate an email address format</title>
		<link>http://www.ruifeio.com/2009/07/02/how-to-validate-an-email-address-format/</link>
		<comments>http://www.ruifeio.com/2009/07/02/how-to-validate-an-email-address-format/#comments</comments>
		<pubDate>Thu, 02 Jul 2009 10:21:10 +0000</pubDate>
		<dc:creator>Rui Miguel Feio</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.ruifeio.com/?p=85</guid>
		<description><![CDATA[There are several ways of validating an email address format. Normally, I do it the following way: 1. I first define the regular expression for the email format: define (&#8220;FORMAT&#8221;,&#8221;^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$&#8221;); 2. To validate the email address provided is correct: if ( !eregi (FORMAT, $email)) echo &#8220;The email provided has an invalid format&#8221;; Regular expressions can [...]]]></description>
			<content:encoded><![CDATA[<p>There are several ways of validating an email address format.</p>
<p>Normally, I do it the following way:</p>
<p><strong>1. I first define the regular expression for the email format:</strong></p>
<p>define (&#8220;FORMAT&#8221;,&#8221;^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$&#8221;);</p>
<p><strong>2. To validate the email address provided is correct:</strong></p>
<p>if ( !eregi (FORMAT, $email)) echo &#8220;The email provided has an invalid format&#8221;;</p>
<hr />Regular expressions can be a pain to understand and if it&#8217;s hard for you then I would recommend you read &#8220;<a title="Check out book - Sams Teach Yourself Regular Expressions in 10 minutes" href="http://www.ruifeio.com/sams-teach-yourself-regular-expressions-10-minutes-book" onclick="return TrackClick('http%3A%2F%2Fwww.ruifeio.com%2Fsams-teach-yourself-regular-expressions-10-minutes-book','Check+out+book+-+Sams+Teach+Yourself+Regular+Expressions+in+10+minutes')" target="_blank">Sams Teach Yourself Regular Expressions in 10 Minutes</a>&#8221; from Ben Forta.</p>
<p>If however you are simply interested in some practical examples that you could use then I recommend &#8220;<a title="Check out book - Regular Expressions Cookbook" href="http://www.ruifeio.com/regular-expressions-cookbook-book" onclick="return TrackClick('http%3A%2F%2Fwww.ruifeio.com%2Fregular-expressions-cookbook-book','Check+out+book+-+Regular+Expressions+Cookbook')" target="_blank">Regular Expressions Cookbook</a>&#8221; from Jan Goyvaerts and Steven Levithan.</p>
<hr />
<div class="fullcircle-social-links" style="display: block;"></div><div style="clear: both;"></div>
<div class="sociable">

<ul>
	<li class="sociablefirst"><a rel="nofollow"  target="_blank" href="mailto:?subject=How%20to%20validate%20an%20email%20address%20format&amp;body=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F02%2Fhow-to-validate-an-email-address-format%2F" title="email"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="javascript:AddToFavorites();" title="Add to favorites"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/addtofavorites.png" title="Add to favorites" alt="Add to favorites" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F02%2Fhow-to-validate-an-email-address-format%2F&amp;t=How%20to%20validate%20an%20email%20address%20format" title="Facebook"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://twitter.com/home?status=How%20to%20validate%20an%20email%20address%20format%20-%20http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F02%2Fhow-to-validate-an-email-address-format%2F" title="Twitter"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F02%2Fhow-to-validate-an-email-address-format%2F&amp;t=How%20to%20validate%20an%20email%20address%20format" title="MySpace"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F02%2Fhow-to-validate-an-email-address-format%2F&amp;title=How%20to%20validate%20an%20email%20address%20format&amp;notes=There%20are%20several%20ways%20of%20validating%20an%20email%20address%20format.%0D%0A%0D%0ANormally%2C%20I%20do%20it%20the%20following%20way%3A%0D%0A%0D%0A1.%20I%20first%20define%20the%20regular%20expression%20for%20the%20email%20format%3A%0D%0A%0D%0Adefine%20%28%22FORMAT%22%2C%22%5E%5B_a-z0-9-%5D%2B%28%5C.%5B_a-z0-9-%5D%2B%29%2A%40%5Ba-z0-9-%5D%2B%28%5C.%5Ba-z0-9-%5D%2B%29%2A%28%5C.%5Ba-z" title="del.icio.us"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F02%2Fhow-to-validate-an-email-address-format%2F&amp;title=How%20to%20validate%20an%20email%20address%20format&amp;source=Rui+Miguel+Feio+Sharing+knowledge+with+the+world&amp;summary=There%20are%20several%20ways%20of%20validating%20an%20email%20address%20format.%0D%0A%0D%0ANormally%2C%20I%20do%20it%20the%20following%20way%3A%0D%0A%0D%0A1.%20I%20first%20define%20the%20regular%20expression%20for%20the%20email%20format%3A%0D%0A%0D%0Adefine%20%28%22FORMAT%22%2C%22%5E%5B_a-z0-9-%5D%2B%28%5C.%5B_a-z0-9-%5D%2B%29%2A%40%5Ba-z0-9-%5D%2B%28%5C.%5Ba-z0-9-%5D%2B%29%2A%28%5C.%5Ba-z" title="LinkedIn"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F02%2Fhow-to-validate-an-email-address-format%2F&amp;title=How%20to%20validate%20an%20email%20address%20format&amp;bodytext=There%20are%20several%20ways%20of%20validating%20an%20email%20address%20format.%0D%0A%0D%0ANormally%2C%20I%20do%20it%20the%20following%20way%3A%0D%0A%0D%0A1.%20I%20first%20define%20the%20regular%20expression%20for%20the%20email%20format%3A%0D%0A%0D%0Adefine%20%28%22FORMAT%22%2C%22%5E%5B_a-z0-9-%5D%2B%28%5C.%5B_a-z0-9-%5D%2B%29%2A%40%5Ba-z0-9-%5D%2B%28%5C.%5Ba-z0-9-%5D%2B%29%2A%28%5C.%5Ba-z" title="Digg"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F02%2Fhow-to-validate-an-email-address-format%2F&amp;title=How%20to%20validate%20an%20email%20address%20format" title="StumbleUpon"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F02%2Fhow-to-validate-an-email-address-format%2F&amp;title=How%20to%20validate%20an%20email%20address%20format&amp;annotation=There%20are%20several%20ways%20of%20validating%20an%20email%20address%20format.%0D%0A%0D%0ANormally%2C%20I%20do%20it%20the%20following%20way%3A%0D%0A%0D%0A1.%20I%20first%20define%20the%20regular%20expression%20for%20the%20email%20format%3A%0D%0A%0D%0Adefine%20%28%22FORMAT%22%2C%22%5E%5B_a-z0-9-%5D%2B%28%5C.%5B_a-z0-9-%5D%2B%29%2A%40%5Ba-z0-9-%5D%2B%28%5C.%5Ba-z0-9-%5D%2B%29%2A%28%5C.%5Ba-z" title="Google Bookmarks"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://buzz.yahoo.com/submit/?submitUrl=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F02%2Fhow-to-validate-an-email-address-format%2F&amp;submitHeadline=How%20to%20validate%20an%20email%20address%20format&amp;submitSummary=There%20are%20several%20ways%20of%20validating%20an%20email%20address%20format.%0D%0A%0D%0ANormally%2C%20I%20do%20it%20the%20following%20way%3A%0D%0A%0D%0A1.%20I%20first%20define%20the%20regular%20expression%20for%20the%20email%20format%3A%0D%0A%0D%0Adefine%20%28%22FORMAT%22%2C%22%5E%5B_a-z0-9-%5D%2B%28%5C.%5B_a-z0-9-%5D%2B%29%2A%40%5Ba-z0-9-%5D%2B%28%5C.%5Ba-z0-9-%5D%2B%29%2A%28%5C.%5Ba-z&amp;submitCategory=science&amp;submitAssetType=text" title="Yahoo! Buzz"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/yahoobuzz.png" title="Yahoo! Buzz" alt="Yahoo! Buzz" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  target="_blank" href="http://www.indianpad.com/submit.php?url=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F02%2Fhow-to-validate-an-email-address-format%2F" title="IndianPad"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/indianpad.png" title="IndianPad" alt="IndianPad" class="sociable-hovers" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.ruifeio.com/2009/07/02/how-to-validate-an-email-address-format/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP security considerations</title>
		<link>http://www.ruifeio.com/2009/07/01/php-security-considerations/</link>
		<comments>http://www.ruifeio.com/2009/07/01/php-security-considerations/#comments</comments>
		<pubDate>Wed, 01 Jul 2009 22:11:09 +0000</pubDate>
		<dc:creator>Rui Miguel Feio</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.ruifeio.com/?p=71</guid>
		<description><![CDATA[When developing a script wether if it&#8217;s in PHP or any other language you should always consider the security aspect. I&#8217;m sure the last thing you want is to get your script (and ultimately your data) hacked. To make sure this does not happen there are a few steps you should pay attention at: Turn [...]]]></description>
			<content:encoded><![CDATA[<p>When developing a script wether if it&#8217;s in PHP or any other language you should always consider the security aspect. I&#8217;m sure the last thing you want is to get your script (and ultimately your data) hacked.</p>
<p>To make sure this does not happen there are a few steps you should pay attention at:</p>
<ol>
<li>Turn OFF the <em>register_globals</em> option</li>
<li>Always declare variables in advance</li>
<li>Check input type, length and format</li>
<li>Use <em>mysql_real_escape_string()</em> before passing values to a MySQL query</li>
<li>Use <em>htmlentities() </em>to convert characters to html entities before passing values to a MySQL query</li>
<li>Turn OFF the error reporting and display</li>
</ol>
<p><strong>Here are some ways on how to achieve these:</strong></p>
<p><strong>1. To turn OFF the <em>register_global</em> option:</strong></p>
<p>Edit your <em>php.ini</em> and turn it OFF or if you don&#8217;t have access to it add the following to the <em>.htaccess</em> file in your server:</p>
<p><em>php_flag register_globals 0</em></p>
<p><strong>2. Always declare variables in advance:</strong></p>
<p>Define default values to all the variables you&#8217;re going to use in the beginning of your script.</p>
<p><strong>3. Check input type, length and format:</strong></p>
<p>Always make sure that the value of the variable is exactly what the script should expect.</p>
<p><span style="text-decoration: underline;">Checking type (example):</span></p>
<p>if ($settype($var, &#8216;integer&#8217;)) exit(&#8220;$var is an invalid value&#8221;);</p>
<p><span style="text-decoration: underline;">Checking length (example):</span></p>
<p>if(strlen($var) &gt; 20) exit (&#8220;$var has to have a maximum of 20 characters&#8221;);</p>
<p><span style="text-decoration: underline;">Checking format (example):</span></p>
<p>$format = &#8220;^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$&#8221;;</p>
<p>if(!eregi($format, $email)) exit(&#8220;$email is not a valid email address&#8221;);</p>
<p><strong>4. Use <em>mysql_real_escape_string()</em> before passing values to a MySQL query</strong></p>
<p>Escape the content of your variables before passing them to a MySQL Query to sanitize the values passed to your data base:</p>
<p>$escaped = mysql_real_escape_string($var);</p>
<p>$action = &#8220;SELECT * FROM table WHERE field = &#8216;$escaped&#8217; &#8220;;</p>
<p><strong>5. Use htmlentities() to convert characters to html entities before passing values to a MySQL query</strong></p>
<p>Another way to sanitize the values passed to your data base is by using the <em>htmlentities() </em>function. This converts special characters to their corresponding HTML code:</p>
<p>$convert= htmlentities($var);</p>
<p>$action = &#8220;SELECT * FROM table WHERE field = &#8216;$convert&#8217; &#8220;;</p>
<p><strong>6.  Turn OFF the error reporting and display</strong></p>
<p>You should never allow the system to show the error messages in your live production server because these messages can provide precious information about your system.</p>
<p>You can either set both <em>error_reporting</em> and <em>display_errors</em> to 0 <em>in php.ini</em> or when you execute the scripts with <em>error_reporting(0)</em> and <em>display_errors(0)</em>.</p>
<hr />If you would like to know more about PHP Security I recommend the book &#8220;<a title="Check out book - Pro PHP Security" href="http://www.ruifeio.com/pro-php-security-book" onclick="return TrackClick('http%3A%2F%2Fwww.ruifeio.com%2Fpro-php-security-book','Check+out+book+-+Pro+PHP+Security')" target="_blank">Pro PHP Security</a>&#8221; from Chris Snyder.</p>
<hr />
<div class="fullcircle-social-links" style="display: block;"></div><div style="clear: both;"></div>
<div class="sociable">

<ul>
	<li class="sociablefirst"><a rel="nofollow"  target="_blank" href="mailto:?subject=PHP%20security%20considerations&amp;body=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F01%2Fphp-security-considerations%2F" title="email"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="javascript:AddToFavorites();" title="Add to favorites"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/addtofavorites.png" title="Add to favorites" alt="Add to favorites" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F01%2Fphp-security-considerations%2F&amp;t=PHP%20security%20considerations" title="Facebook"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://twitter.com/home?status=PHP%20security%20considerations%20-%20http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F01%2Fphp-security-considerations%2F" title="Twitter"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F01%2Fphp-security-considerations%2F&amp;t=PHP%20security%20considerations" title="MySpace"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F01%2Fphp-security-considerations%2F&amp;title=PHP%20security%20considerations&amp;notes=When%20developing%20a%20script%20wether%20if%20it%27s%20in%20PHP%20or%20any%20other%20language%20you%20should%20always%20consider%20the%20security%20aspect.%20I%27m%20sure%20the%20last%20thing%20you%20want%20is%20to%20get%20your%20script%20%28and%20ultimately%20your%20data%29%20hacked.%0D%0A%0D%0ATo%20make%20sure%20this%20does%20not%20happen%20there%20" title="del.icio.us"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F01%2Fphp-security-considerations%2F&amp;title=PHP%20security%20considerations&amp;source=Rui+Miguel+Feio+Sharing+knowledge+with+the+world&amp;summary=When%20developing%20a%20script%20wether%20if%20it%27s%20in%20PHP%20or%20any%20other%20language%20you%20should%20always%20consider%20the%20security%20aspect.%20I%27m%20sure%20the%20last%20thing%20you%20want%20is%20to%20get%20your%20script%20%28and%20ultimately%20your%20data%29%20hacked.%0D%0A%0D%0ATo%20make%20sure%20this%20does%20not%20happen%20there%20" title="LinkedIn"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F01%2Fphp-security-considerations%2F&amp;title=PHP%20security%20considerations&amp;bodytext=When%20developing%20a%20script%20wether%20if%20it%27s%20in%20PHP%20or%20any%20other%20language%20you%20should%20always%20consider%20the%20security%20aspect.%20I%27m%20sure%20the%20last%20thing%20you%20want%20is%20to%20get%20your%20script%20%28and%20ultimately%20your%20data%29%20hacked.%0D%0A%0D%0ATo%20make%20sure%20this%20does%20not%20happen%20there%20" title="Digg"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F01%2Fphp-security-considerations%2F&amp;title=PHP%20security%20considerations" title="StumbleUpon"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F01%2Fphp-security-considerations%2F&amp;title=PHP%20security%20considerations&amp;annotation=When%20developing%20a%20script%20wether%20if%20it%27s%20in%20PHP%20or%20any%20other%20language%20you%20should%20always%20consider%20the%20security%20aspect.%20I%27m%20sure%20the%20last%20thing%20you%20want%20is%20to%20get%20your%20script%20%28and%20ultimately%20your%20data%29%20hacked.%0D%0A%0D%0ATo%20make%20sure%20this%20does%20not%20happen%20there%20" title="Google Bookmarks"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://buzz.yahoo.com/submit/?submitUrl=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F01%2Fphp-security-considerations%2F&amp;submitHeadline=PHP%20security%20considerations&amp;submitSummary=When%20developing%20a%20script%20wether%20if%20it%27s%20in%20PHP%20or%20any%20other%20language%20you%20should%20always%20consider%20the%20security%20aspect.%20I%27m%20sure%20the%20last%20thing%20you%20want%20is%20to%20get%20your%20script%20%28and%20ultimately%20your%20data%29%20hacked.%0D%0A%0D%0ATo%20make%20sure%20this%20does%20not%20happen%20there%20&amp;submitCategory=science&amp;submitAssetType=text" title="Yahoo! Buzz"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/yahoobuzz.png" title="Yahoo! Buzz" alt="Yahoo! Buzz" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  target="_blank" href="http://www.indianpad.com/submit.php?url=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F01%2Fphp-security-considerations%2F" title="IndianPad"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/indianpad.png" title="IndianPad" alt="IndianPad" class="sociable-hovers" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.ruifeio.com/2009/07/01/php-security-considerations/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to identify a MySQL query problem</title>
		<link>http://www.ruifeio.com/2009/07/01/how-to-identify-the-mysql-query-problem/</link>
		<comments>http://www.ruifeio.com/2009/07/01/how-to-identify-the-mysql-query-problem/#comments</comments>
		<pubDate>Wed, 01 Jul 2009 20:38:24 +0000</pubDate>
		<dc:creator>Rui Miguel Feio</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.ruifeio.com/?p=65</guid>
		<description><![CDATA[Sometimes you happen to have a problem with one of your MySQL queries and you simply can&#8217;t seem to understand why. Well, one thing that helps is to use the mysql_error() function. This function returns the message of the MySQL error you&#8217;re getting. Example: $action = &#8220;INSERT INTO table (name, address, dob) VALUES (&#8216;$name&#8217;, &#8216;$address&#8217;, [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes you happen to have a problem with one of your MySQL queries and you simply can&#8217;t seem to understand why.</p>
<p>Well, one thing that helps is to use the <em>mysql_error()</em> function.</p>
<p>This function returns the message of the MySQL error you&#8217;re getting.</p>
<p><strong>Example:</strong></p>
<p>$action = &#8220;INSERT INTO table (name, address, dob) VALUES (&#8216;$name&#8217;, &#8216;$address&#8217;, &#8216;$dob&#8217;)&#8221;;<br />
$query = mysql_query($action) or <strong>die(mysql_error())</strong>;</p>
<p>If we happen to get a problem with our MySQL error the script execution will stop (by using the <em>die()</em> function) and the MySQL error message will be returned (by using the <em>mysql_error()</em> function).</p>
<div class="fullcircle-social-links" style="display: block;"></div><div style="clear: both;"></div>
<div class="sociable">

<ul>
	<li class="sociablefirst"><a rel="nofollow"  target="_blank" href="mailto:?subject=How%20to%20identify%20a%20MySQL%20query%20problem&amp;body=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F01%2Fhow-to-identify-the-mysql-query-problem%2F" title="email"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="javascript:AddToFavorites();" title="Add to favorites"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/addtofavorites.png" title="Add to favorites" alt="Add to favorites" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F01%2Fhow-to-identify-the-mysql-query-problem%2F&amp;t=How%20to%20identify%20a%20MySQL%20query%20problem" title="Facebook"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://twitter.com/home?status=How%20to%20identify%20a%20MySQL%20query%20problem%20-%20http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F01%2Fhow-to-identify-the-mysql-query-problem%2F" title="Twitter"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F01%2Fhow-to-identify-the-mysql-query-problem%2F&amp;t=How%20to%20identify%20a%20MySQL%20query%20problem" title="MySpace"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F01%2Fhow-to-identify-the-mysql-query-problem%2F&amp;title=How%20to%20identify%20a%20MySQL%20query%20problem&amp;notes=Sometimes%20you%20happen%20to%20have%20a%20problem%20with%20one%20of%20your%20MySQL%20queries%20and%20you%20simply%20can%27t%20seem%20to%20understand%20why.%0D%0A%0D%0AWell%2C%20one%20thing%20that%20helps%20is%20to%20use%20the%20mysql_error%28%29%20function.%0D%0A%0D%0AThis%20function%20returns%20the%20message%20of%20the%20MySQL%20error%20you%27re%20gett" title="del.icio.us"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F01%2Fhow-to-identify-the-mysql-query-problem%2F&amp;title=How%20to%20identify%20a%20MySQL%20query%20problem&amp;source=Rui+Miguel+Feio+Sharing+knowledge+with+the+world&amp;summary=Sometimes%20you%20happen%20to%20have%20a%20problem%20with%20one%20of%20your%20MySQL%20queries%20and%20you%20simply%20can%27t%20seem%20to%20understand%20why.%0D%0A%0D%0AWell%2C%20one%20thing%20that%20helps%20is%20to%20use%20the%20mysql_error%28%29%20function.%0D%0A%0D%0AThis%20function%20returns%20the%20message%20of%20the%20MySQL%20error%20you%27re%20gett" title="LinkedIn"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F01%2Fhow-to-identify-the-mysql-query-problem%2F&amp;title=How%20to%20identify%20a%20MySQL%20query%20problem&amp;bodytext=Sometimes%20you%20happen%20to%20have%20a%20problem%20with%20one%20of%20your%20MySQL%20queries%20and%20you%20simply%20can%27t%20seem%20to%20understand%20why.%0D%0A%0D%0AWell%2C%20one%20thing%20that%20helps%20is%20to%20use%20the%20mysql_error%28%29%20function.%0D%0A%0D%0AThis%20function%20returns%20the%20message%20of%20the%20MySQL%20error%20you%27re%20gett" title="Digg"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F01%2Fhow-to-identify-the-mysql-query-problem%2F&amp;title=How%20to%20identify%20a%20MySQL%20query%20problem" title="StumbleUpon"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F01%2Fhow-to-identify-the-mysql-query-problem%2F&amp;title=How%20to%20identify%20a%20MySQL%20query%20problem&amp;annotation=Sometimes%20you%20happen%20to%20have%20a%20problem%20with%20one%20of%20your%20MySQL%20queries%20and%20you%20simply%20can%27t%20seem%20to%20understand%20why.%0D%0A%0D%0AWell%2C%20one%20thing%20that%20helps%20is%20to%20use%20the%20mysql_error%28%29%20function.%0D%0A%0D%0AThis%20function%20returns%20the%20message%20of%20the%20MySQL%20error%20you%27re%20gett" title="Google Bookmarks"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://buzz.yahoo.com/submit/?submitUrl=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F01%2Fhow-to-identify-the-mysql-query-problem%2F&amp;submitHeadline=How%20to%20identify%20a%20MySQL%20query%20problem&amp;submitSummary=Sometimes%20you%20happen%20to%20have%20a%20problem%20with%20one%20of%20your%20MySQL%20queries%20and%20you%20simply%20can%27t%20seem%20to%20understand%20why.%0D%0A%0D%0AWell%2C%20one%20thing%20that%20helps%20is%20to%20use%20the%20mysql_error%28%29%20function.%0D%0A%0D%0AThis%20function%20returns%20the%20message%20of%20the%20MySQL%20error%20you%27re%20gett&amp;submitCategory=science&amp;submitAssetType=text" title="Yahoo! Buzz"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/yahoobuzz.png" title="Yahoo! Buzz" alt="Yahoo! Buzz" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  target="_blank" href="http://www.indianpad.com/submit.php?url=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F07%2F01%2Fhow-to-identify-the-mysql-query-problem%2F" title="IndianPad"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/indianpad.png" title="IndianPad" alt="IndianPad" class="sociable-hovers" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.ruifeio.com/2009/07/01/how-to-identify-the-mysql-query-problem/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Session not being passed from a web site to WordPress</title>
		<link>http://www.ruifeio.com/2009/06/30/php-session-not-being-from-site-to-wordpress/</link>
		<comments>http://www.ruifeio.com/2009/06/30/php-session-not-being-from-site-to-wordpress/#comments</comments>
		<pubDate>Tue, 30 Jun 2009 13:14:34 +0000</pubDate>
		<dc:creator>Rui Miguel Feio</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.ruifeio.com/?p=38</guid>
		<description><![CDATA[Recently I had this case where a PHP session ($_SESSION) was not being passed from a web site to WordPress. Basically, WordPress was installed and configured to be part of a web site and there was the need to use Sessions to control the login/logout process of the site. Although the session_start() had been defined [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I had this case where a PHP session ($_SESSION) was not being passed from a web site to WordPress.</p>
<p>Basically, WordPress was installed and configured to be part of a web site and there was the need to use Sessions to control the login/logout process of the site.</p>
<p>Although the session_start() had been defined to WordPress, the latter did not recognize the session values and therefore simply ignored if a user was logged on.</p>
<p>After some research and some brainstorming with some great experts on the field, I realized that the problem was in the WordPress URL itself.</p>
<p>The problem was that although the domain was the same, WordPress was suppressing the &#8220;www&#8221; from the URL which caused the $_SESSION values not to be recognized.</p>
<p><strong>Example:</strong></p>
<p>Site URL: http://www.this-is-an-example.com</p>
<p>WP URL: http://this-is-an-example.com  (missing the &#8220;www.&#8221;)</p>
<p><strong>Solution:</strong></p>
<p>By adding the &#8220;www.&#8221; to the WordPress domain name the problem was solved:</p>
<ol>
<li>Login to WordPress Admin area</li>
<li>Go to <em>Settings</em> &#8211; <em>General</em></li>
<li>Add &#8220;www.&#8221; to the WordPress address (URL) and Blog address (URL).</li>
</ol>
<div class="fullcircle-social-links" style="display: block;"></div><div style="clear: both;"></div>
<div class="sociable">

<ul>
	<li class="sociablefirst"><a rel="nofollow"  target="_blank" href="mailto:?subject=PHP%20Session%20not%20being%20passed%20from%20a%20web%20site%20to%20WordPress&amp;body=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F06%2F30%2Fphp-session-not-being-from-site-to-wordpress%2F" title="email"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="javascript:AddToFavorites();" title="Add to favorites"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/addtofavorites.png" title="Add to favorites" alt="Add to favorites" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F06%2F30%2Fphp-session-not-being-from-site-to-wordpress%2F&amp;t=PHP%20Session%20not%20being%20passed%20from%20a%20web%20site%20to%20WordPress" title="Facebook"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://twitter.com/home?status=PHP%20Session%20not%20being%20passed%20from%20a%20web%20site%20to%20WordPress%20-%20http%3A%2F%2Fwww.ruifeio.com%2F2009%2F06%2F30%2Fphp-session-not-being-from-site-to-wordpress%2F" title="Twitter"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F06%2F30%2Fphp-session-not-being-from-site-to-wordpress%2F&amp;t=PHP%20Session%20not%20being%20passed%20from%20a%20web%20site%20to%20WordPress" title="MySpace"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F06%2F30%2Fphp-session-not-being-from-site-to-wordpress%2F&amp;title=PHP%20Session%20not%20being%20passed%20from%20a%20web%20site%20to%20WordPress&amp;notes=Recently%20I%20had%20this%20case%20where%20a%20PHP%20session%20%28%24_SESSION%29%20was%20not%20being%20passed%20from%20a%20web%20site%20to%20WordPress.%0D%0A%0D%0ABasically%2C%20WordPress%20was%20installed%20and%20configured%20to%20be%20part%20of%20a%20web%20site%20and%20there%20was%20the%20need%20to%20use%20Sessions%20to%20control%20the%20login%2Flogo" title="del.icio.us"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F06%2F30%2Fphp-session-not-being-from-site-to-wordpress%2F&amp;title=PHP%20Session%20not%20being%20passed%20from%20a%20web%20site%20to%20WordPress&amp;source=Rui+Miguel+Feio+Sharing+knowledge+with+the+world&amp;summary=Recently%20I%20had%20this%20case%20where%20a%20PHP%20session%20%28%24_SESSION%29%20was%20not%20being%20passed%20from%20a%20web%20site%20to%20WordPress.%0D%0A%0D%0ABasically%2C%20WordPress%20was%20installed%20and%20configured%20to%20be%20part%20of%20a%20web%20site%20and%20there%20was%20the%20need%20to%20use%20Sessions%20to%20control%20the%20login%2Flogo" title="LinkedIn"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F06%2F30%2Fphp-session-not-being-from-site-to-wordpress%2F&amp;title=PHP%20Session%20not%20being%20passed%20from%20a%20web%20site%20to%20WordPress&amp;bodytext=Recently%20I%20had%20this%20case%20where%20a%20PHP%20session%20%28%24_SESSION%29%20was%20not%20being%20passed%20from%20a%20web%20site%20to%20WordPress.%0D%0A%0D%0ABasically%2C%20WordPress%20was%20installed%20and%20configured%20to%20be%20part%20of%20a%20web%20site%20and%20there%20was%20the%20need%20to%20use%20Sessions%20to%20control%20the%20login%2Flogo" title="Digg"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F06%2F30%2Fphp-session-not-being-from-site-to-wordpress%2F&amp;title=PHP%20Session%20not%20being%20passed%20from%20a%20web%20site%20to%20WordPress" title="StumbleUpon"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F06%2F30%2Fphp-session-not-being-from-site-to-wordpress%2F&amp;title=PHP%20Session%20not%20being%20passed%20from%20a%20web%20site%20to%20WordPress&amp;annotation=Recently%20I%20had%20this%20case%20where%20a%20PHP%20session%20%28%24_SESSION%29%20was%20not%20being%20passed%20from%20a%20web%20site%20to%20WordPress.%0D%0A%0D%0ABasically%2C%20WordPress%20was%20installed%20and%20configured%20to%20be%20part%20of%20a%20web%20site%20and%20there%20was%20the%20need%20to%20use%20Sessions%20to%20control%20the%20login%2Flogo" title="Google Bookmarks"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://buzz.yahoo.com/submit/?submitUrl=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F06%2F30%2Fphp-session-not-being-from-site-to-wordpress%2F&amp;submitHeadline=PHP%20Session%20not%20being%20passed%20from%20a%20web%20site%20to%20WordPress&amp;submitSummary=Recently%20I%20had%20this%20case%20where%20a%20PHP%20session%20%28%24_SESSION%29%20was%20not%20being%20passed%20from%20a%20web%20site%20to%20WordPress.%0D%0A%0D%0ABasically%2C%20WordPress%20was%20installed%20and%20configured%20to%20be%20part%20of%20a%20web%20site%20and%20there%20was%20the%20need%20to%20use%20Sessions%20to%20control%20the%20login%2Flogo&amp;submitCategory=science&amp;submitAssetType=text" title="Yahoo! Buzz"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/yahoobuzz.png" title="Yahoo! Buzz" alt="Yahoo! Buzz" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  target="_blank" href="http://www.indianpad.com/submit.php?url=http%3A%2F%2Fwww.ruifeio.com%2F2009%2F06%2F30%2Fphp-session-not-being-from-site-to-wordpress%2F" title="IndianPad"><img src="http://www.ruifeio.com/wp-content/plugins/sociable/images/indianpad.png" title="IndianPad" alt="IndianPad" class="sociable-hovers" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.ruifeio.com/2009/06/30/php-session-not-being-from-site-to-wordpress/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
	</channel>
</rss>
