<?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>No Stylesheets</title>
	<atom:link href="http://nostylesheets.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://nostylesheets.com</link>
	<description>Why would one use stylesheets?</description>
	<lastBuildDate>Mon, 12 Nov 2012 08:14:19 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.2</generator>
		<item>
		<title>The complete Magento upgrade guide</title>
		<link>http://nostylesheets.com/2012/11/09/the-complete-magento-upgrade-guide/</link>
		<comments>http://nostylesheets.com/2012/11/09/the-complete-magento-upgrade-guide/#comments</comments>
		<pubDate>Fri, 09 Nov 2012 17:09:16 +0000</pubDate>
		<dc:creator>Rick</dc:creator>
				<category><![CDATA[Magento]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://nostylesheets.com/?p=515</guid>
		<description><![CDATA[A manual for how to upgrade to the latest version from 1.4.x, 1.5.x or 1.6.x. ]]></description>
			<content:encoded><![CDATA[<p>After having upgraded several Magento sites and having read alot of online upgrade guides, I decided to write my own manual. Many people search for how-to&#8217;s for specific Magento versions, but it actually doesn&#8217;t really matter what version of Magento you are upgrading. The only difference is that you need to upgrade to 1.4.2 if you are running a version below that. Magento stopped using PEAR as of version 1.4.2.</p>
<h2>Preparations</h2>
<p>First of all, backup your production site and create a staging environment. After setting the new database connection in <strong>app/etc/local.xml</strong>, manually change the website urls in the database:</p>
<pre>UPDATE
   `core_config_data`
SET
   `value` = REPLACE(`value`, "//www.yourwebsite.com", "//staging.yourwebsite.com");</pre>
<p>Now login to the new staging Admin panel and disable all cache under Cache Management and delete the <strong>var/cache</strong> and <strong>var/session</strong> folders in your root directory. It is important to clean up and reduce the size of the database before we start the upgrade process, since large databases take forever to upgrade and corrupt databases can cause headaches when debugging.</p>
<p>If you have the Magento Compiler enabled, run the following commands to remove all compiled files and to disable the include path.</p>
<pre class="ssh">$ php shell/compiler.php disable
$ php shell/compiler.php clear</pre>
<p>Make sure that the staging website maintains all proper file and folder permissions. If this is not the case you can reset them by <a href="http://www.magentocommerce.com/wiki/groups/227/resetting_file_permissions" target="_blank">following this guide</a>.</p>
<h2>Cleanup the database</h2>
<p>Since Magento logs <strong>alot</strong>, let&#8217;s clean up a bit first.  Enter the following command to view how much data Magento has been logging until now.</p>
<pre class="ssh">$ shell/log.php status</pre>
<p>This displays the size of the `log_` and `report_` tables. If you haven&#8217;t enabled Log Cleaning in the Magento Admin (System &gt; Configuration &gt; System &gt; Log Cleaning), this can quickly grow to a couple of hundred MB or maybe some GB&#8217;s!<br />
You can manually cleanup these tables by running this command:</p>
<pre class="ssh">$ shell/log.php clean</pre>
<p>However there are more tables that can be emptied. You can safely run this query:</p>
<pre class="sql">TRUNCATE `catalog_compare_item`;
TRUNCATE `dataflow_batch_export`;
TRUNCATE `dataflow_batch_import`;
TRUNCATE `log_customer`;
TRUNCATE `log_quote`;
TRUNCATE `log_summary`;
TRUNCATE `log_summary_type`;
TRUNCATE `log_url`;
TRUNCATE `log_url_info`;
TRUNCATE `log_visitor`;
TRUNCATE `log_visitor_info`;
TRUNCATE `log_visitor_online`;
TRUNCATE `report_viewed_product_index`;
TRUNCATE `report_compared_product_index`;
TRUNCATE `report_event`;
TRUNCATE `sales_flat_quote_item`;</pre>
<p>You could also truncate the `core_url_rewrite` table, which can grow pretty large too if you have alot of products and websites/stores-views. <strong>Attention: When emptying this you will lose all old url redirects for products, categories, cms pages, etc</strong>, but it greatly increases the speed of the upgrade process. Of course it is safe to do this when the website is not yet in production in the first place.</p>
<p>This should leave us with a pretty slimmed down version of the database.</p>
<p>Now reindex the database to be sure</p>
<pre class="ssh">$ php shell/indexer.php reindexall</pre>
<p>Clear cache again if Magento somehow managed to create some (you can&#8217;t do this enough! <img src='http://nostylesheets.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> )</p>
<pre class="ssh">$ rm -rf var/cache var/session</pre>
<p><strong>Important reminder:</strong> do not access the staging website in your browser! As this will initiate the upgrade process too early</p>
<h2>Fix corrupt database (don&#8217;t skip this step!!)</h2>
<h4>Check for corrupt structure</h4>
<p>It&#8217;s possible that the database structure has been changed after the moment is was installed, due to plugins or custom code. Magento has released a tool that can fix corrupted databases: <a href="http://www.magentocommerce.com/wiki/1_-_installation_and_configuration/db-repair-tool" target="_blank">The Magento Database repair tool</a>. It adds missing table columns, foreign keys and indexes. Download the php script and upload it to the root of your staging website. Now create a fresh install of Magento of the same version as your current shop, so we can compare it&#8217;s database-structure with our staging database.</p>
<p>Run the tool and see if it makes some changes. If an error occurs, just run the tool again until it says there is nothing more to change.</p>
<h4>Check for corrupt data</h4>
<p>Besides the structure of tables, it&#8217;s also possible that some data is corrupted. I&#8217;ve had cases that duplicate order records existed that messed up the upgrade process. Run this query to find out whether there are duplicate records and delete them.</p>
<pre class="sql">SELECT `increment_id` FROM `sales_flat_order` GROUP BY `increment_id` HAVING COUNT(*)&gt;1;
SELECT `increment_id` FROM `sales_flat_order_grid` GROUP BY `increment_id` HAVING COUNT(*)&gt;1;</pre>
<p>More info on this can be found in <a href="http://www.magentocommerce.com/boards/viewthread/221281/" target="_blank">this thread</a>.</p>
<p>Personally I&#8217;ve never had other tables that contained duplicate records.</p>
<h2>Upgrade the Magento core files</h2>
<p>As mentioned earlier, if you are running Magento 1.4.1.x or lower you need to upgrade to 1.4.2 first.</p>
<pre class="ssh">$ chmod -R 777 lib/PEAR
$ ./pear mage-setup
$ ./pear upgrade -f magento-core/Mage_All_latest-stable
$ chmod 550 ./mage
$ ./mage mage-setup
$ ./mage sync</pre>
<p>If pear displays errors, if may have to be upgraded.</p>
<pre>$ ./pear channel-update pear.php.net
$ ./pear upgrade --force PEAR</pre>
<p>Repeat this step if it shows any errors</p>
<p>The following steps apply to all versions of Magento (1.4.2 and higher) that want to upgrade to the latest stable version (currently 1.7.0.2). <strong>Reminder: unfortunately it&#8217;s not possible to upgrade to a version other than the latest release. If you really need this, you need to manually download the specific version of Magento and connect the older database to initiate the upgrade process</strong>.</p>
<p>View which packages can be upgraded</p>
<pre>$ ./mage list-upgrades</pre>
<p>Configure Magento to upgrade to the latest stable version, as we do not want a bèta version. (Bèta state is default!)</p>
<pre>$ ./mage config-set preferred_state stable</pre>
<p>Upgrade all packages! This will also upgrade any plugin installed via SSH if possible. Magento will replace all php files in the app/code/core and in the app/design/base/default map<br />
Custom theme files and php files from app/code/local remain untouched!</p>
<pre>$ ./mage upgrade-all --force</pre>
<p>The filesystem has now been fully upgraded.</p>
<h2>Upgrade the database</h2>
<p>Since all package files on the server have been upgraded. Magento will check for version changes when a page is loaded in the browser. All packages will execute the upgrade php scripts which change the database structure. Now open the staging website in your browser and Magento will start the upgrade. You can monitor this progress via SSH:</p>
<pre>$ mysql -h YOUR_DB_HOST -u YOUR_DB_USER -D YOUR_DB_NAME -p</pre>
<pre>&gt; SHOW FULL PROCESSLIST;</pre>
<p>Depending on your database size, this process can be ready in a few minutes or can take up a few hours. I usually like to refresh the processlist every 10 minutes to see what Magento is up to. If anything goes wrong, you&#8217;ll at least know where to look <img src='http://nostylesheets.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . It is important not to open the site in another browser during the process, so be sure that no-one else does too.</p>
<p>When the process is finished (no more activity in the mysql processlist), close the browser and clear cache.</p>
<pre class="ssh">$ rm -rf var/cache var/session</pre>
<h2>Finishing up</h2>
<p>To be sure the database upgrade was succesful, run the Magento Database Repair tool again. Now you&#8217;ll need a fresh database of the latest Magento version to compare against, so create this first.<br />
If the upgrade went ok, the tool shouldn&#8217;t find any differences.</p>
<p>The last step is to reindex everything again!</p>
<pre class="ssh">$ php shell/indexer.php reindexall</pre>
<p>The upgrade is now complete! You can safely open the website in the browser and see if everything still works. Remember: All errors are almost always related to corrupt database structure, custom theme files, incompatible plugins or custom code (app/code/community and app/code/local).</p>
]]></content:encoded>
			<wfw:commentRss>http://nostylesheets.com/2012/11/09/the-complete-magento-upgrade-guide/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>IE, SSL and file downloads</title>
		<link>http://nostylesheets.com/2012/06/21/ie-ssl-and-file-downloads/</link>
		<comments>http://nostylesheets.com/2012/06/21/ie-ssl-and-file-downloads/#comments</comments>
		<pubDate>Thu, 21 Jun 2012 08:44:42 +0000</pubDate>
		<dc:creator>jeroen</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://nostylesheets.com/?p=505</guid>
		<description><![CDATA[A small reminder for everyone developing applications using SSL (Secure Sockets Layer) for data encryption: When downloading files Internet Explorer has to use it&#8217;s cache in order to be able to open the file. http://support.microsoft.com/kb/316431 states: In order for Internet Explorer to open documents in Office (or any out-of-process, ActiveX document server), Internet Explorer must [...]]]></description>
			<content:encoded><![CDATA[<p>A small reminder for everyone developing applications using SSL (Secure Sockets Layer) for data encryption: When downloading files Internet Explorer has to use it&#8217;s cache in order to be able to open the file. <a href="http://support.microsoft.com/kb/316431" target="_blank">http://support.microsoft.com/kb/316431</a> states:</p>
<blockquote><p>In order for Internet Explorer to open documents in Office (or any out-of-process, ActiveX document server), Internet Explorer must save the file to the local cache directory and ask the associated application to load the file by using IPersistFile::Load. If the file is not stored to disk, this operation fails.</p>
<p>When Internet Explorer communicates with a secure Web site through SSL, Internet Explorer enforces any no-cache request. If the header or headers are present, Internet Explorer does not cache the file. Consequently, Office cannot open the file.</p></blockquote>
<p>This means that IE should always be forced to cache the file before opening. In PHP this is achieved by sending the following HTTP headers,:</p>
<div class="code">

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Do not use header(&quot;Pragma: no-cache&quot;);</span>
<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Pragma: private&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// Do not use header(&quot;Cache-Control: must-revalidate, post-check=0, pre-check=0&quot;);</span>
<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Cache-Control: cache&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

</div>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://nostylesheets.com/2012/06/21/ie-ssl-and-file-downloads/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Remove admin-bar WordPress 3.1</title>
		<link>http://nostylesheets.com/2011/03/18/remove-admin-bar-wordpress-3-1/</link>
		<comments>http://nostylesheets.com/2011/03/18/remove-admin-bar-wordpress-3-1/#comments</comments>
		<pubDate>Fri, 18 Mar 2011 20:57:47 +0000</pubDate>
		<dc:creator>Bernhard</dc:creator>
				<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://nostylesheets.com/?p=488</guid>
		<description><![CDATA[WordPress 3.1 is released and comes with many new features. One of them is the extra admin bar visible at the front-end of your website when user are logged in: Not everyone is happy with this new feature. Here is the way to disable it for project: Open functions.php and add: // Disable admin-bar from [...]]]></description>
			<content:encoded><![CDATA[<p>WordPress 3.1 is released and comes with many new features. One of them is the extra admin bar visible at the front-end of your website when user are logged in:</p>
<p><img class="alignnone size-full wp-image-492" title="adminbar" src="http://nostylesheets.com/files/2011/03/adminbar.png" alt="adminbar" width="476" height="37" /></p>
<p>Not everyone is happy with this new feature. Here is the way to disable it for project:</p>
<p>Open <strong>functions.php</strong> and add:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Disable admin-bar from showing on your blog</span>
wp_deregister_script<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'admin-bar'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
wp_deregister_style<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'admin-bar'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
remove_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp_footer'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'wp_admin_bar_render'</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">1000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://nostylesheets.com/2011/03/18/remove-admin-bar-wordpress-3-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Disable resizing textarea&#8217;s in Chrome and Firefox 4</title>
		<link>http://nostylesheets.com/2011/03/18/disable-resizing-textare-in-chrome/</link>
		<comments>http://nostylesheets.com/2011/03/18/disable-resizing-textare-in-chrome/#comments</comments>
		<pubDate>Fri, 18 Mar 2011 13:53:12 +0000</pubDate>
		<dc:creator>Bernhard</dc:creator>
				<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://nostylesheets.com/?p=481</guid>
		<description><![CDATA[When I was building a new form for a new project today I was having some problems with the resize option for textarea&#8217;s in Chrome (update: and Firefox 4). Every form with a textarea messes up the entire website layout by resizing this field. Example: textarea &#123; resize: none; &#125; I know this can be [...]]]></description>
			<content:encoded><![CDATA[<p>When I was building a new form for a new project today I was having some problems with the resize option for textarea&#8217;s in Chrome (update: and Firefox 4). Every form with a textarea messes up the entire website layout by resizing this field.</p>
<p>Example:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">textarea <span style="color: #00AA00;">&#123;</span>
	resize<span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>I know this can be an usability thing for Chrome and Firefox users, but I think when you make your textarea large enough there should be no problem at all.</p>
]]></content:encoded>
			<wfw:commentRss>http://nostylesheets.com/2011/03/18/disable-resizing-textare-in-chrome/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Facebook PHP SDK for Canvas and FB Login</title>
		<link>http://nostylesheets.com/2011/01/10/facebook-php-sdk-for-canvas-and-fb-login/</link>
		<comments>http://nostylesheets.com/2011/01/10/facebook-php-sdk-for-canvas-and-fb-login/#comments</comments>
		<pubDate>Mon, 10 Jan 2011 21:49:32 +0000</pubDate>
		<dc:creator>Jop</dc:creator>
				<category><![CDATA[Facebook]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Facebook Canvas]]></category>
		<category><![CDATA[Facebook Connect]]></category>
		<category><![CDATA[Facebook Login]]></category>
		<category><![CDATA[Facebook PHP SDK]]></category>

		<guid isPermaLink="false">http://nostylesheets.com/?p=475</guid>
		<description><![CDATA[This is a short article on how to best implement the Facebook PHP SDK for two integration methods: Canvas applications and external websites offering Facebook Login to their visitors. The difference is not very well documented in the example provided with the SDK. Facebook Login (previously Connect) This method is used by external websites, offering [...]]]></description>
			<content:encoded><![CDATA[<p>This is a short article on how to best implement the Facebook PHP SDK for two integration methods: <a href="http://developers.facebook.com/docs/guides/canvas" target="_blank">Canvas applications</a> and external websites offering <a href="http://developers.facebook.com/docs/guides/web#login" target="_blank">Facebook Login</a> to their visitors. The difference is not very well documented in <a href="https://github.com/facebook/php-sdk/blob/master/examples/example.php" target="_blank">the example</a> provided with the SDK.<span id="more-475"></span></p>
<h2>Facebook Login (previously Connect)</h2>
<p>This method is used by external websites, offering their visitors an easy method of registration and login, using their Facebook account. As shown in the <a href="https://github.com/facebook/php-sdk/blob/master/examples/example.php" target="_blank">example code provided with the SDK</a>, we first create an instance of the facebook class, which we use to retreive a session.</p>
<p>We will not find a session in two cases:</p>
<ol>
<li>The visitor has not authorised the website in the past</li>
<li>The method <code>getSession()</code> cannot find the <code>signed_request</code> or <code>session</code> variable in the $_COOKIE or $_REQUEST variables</li>
</ol>
<p>To be sure that the visitor has not authorised your application in the past, we transfer the visitor to Facebook using the method <code>getLoginStatusUrl()</code>. This will header the visitor to Facebook, which in turn headers the visitor back to the referring URL including a $_REQUEST['session'] variable, if the visitor has indeed authorised in the past. Be sure to build in a check to only check this once a session, otherwise this will result in a loop if the user is unknown.</p>
<h2>Canvas</h2>
<p>When using <a href="http://developers.facebook.com/docs/guides/canvas" target="_blank">Facebook Canvas</a> (a website iframed within Facebook), the requested page within the iframe is always provided a <code>signed_request</code> which the SDK uses to build a &#8220;session&#8221;. This means that we always know whether the visitor is an authorised user or not, making the  <code>getLoginStatusUrl()</code> superfluous. If we can&#8217;t find a session (<code>getSession()</code>), or we can&#8217;t find &#8220;<a href="https://graph.facebook.com/me" target="_blank"><code>/me</code></a>&#8220;, the user has not authorised and we need to present the authorisation button.</p>
<p>The following graphic depicts the flow for both cases:</p>
<p><img class="alignnone" title="Facebook PHP SDK login sequence" src="https://docs.google.com/drawings/pub?id=1ot4mZ8YTJTCkkKwyqAffjEHkUGmp2BsLMDMo87tGKvI&amp;w=891&amp;h=792" alt="" width="600" height="533" /></p>
<p>Of course, the above can also be established with the Javascript SDK, but a little dedudancy won&#8217;t do any harm. And the getLoginStatusUrl method is probably a lot quicker than the JS variant.</p>
]]></content:encoded>
			<wfw:commentRss>http://nostylesheets.com/2011/01/10/facebook-php-sdk-for-canvas-and-fb-login/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Htaccess redirect with a space in the URL</title>
		<link>http://nostylesheets.com/2010/04/06/htaccess-redirect-with-a-space-in-the-url/</link>
		<comments>http://nostylesheets.com/2010/04/06/htaccess-redirect-with-a-space-in-the-url/#comments</comments>
		<pubDate>Tue, 06 Apr 2010 15:04:04 +0000</pubDate>
		<dc:creator>roel</dc:creator>
				<category><![CDATA[Etcetera]]></category>

		<guid isPermaLink="false">http://nostylesheets.com/?p=330</guid>
		<description><![CDATA[I discovered something new today how you can use a space in a htaccess file: How can you safely redirect web site traffic from your old pages to the new pages without losing your high search engine rankings? You can do this by using a &#8220;301 redirect&#8220;. But what do you have to do if [...]]]></description>
			<content:encoded><![CDATA[<p>I discovered something new today how you can use a space in a htaccess file:</p>
<p>How can you safely redirect web site traffic from your old pages to the new pages without losing your high search engine rankings?<br />
You can do this by using a &#8220;<a title="301 redirect" href="http://en.wikipedia.org/wiki/301_redirect#HTTP_status_codes_3xx" target="_blank">301 redirect</a>&#8220;.</p>
<p>But what do you have to do if there is a space in the old URL:</p>
<pre>^about nostylesheets.html$</pre>
<p>Normally I would use this to make the URL working:</p>
<pre>^about%20nostylesheets.html$</pre>
<p>But this doesn&#8217;t work.<br />
To make an URL working you just have to use quotes to make this URL working:</p>
<pre>"^about nostylesheets.html$"</pre>
]]></content:encoded>
			<wfw:commentRss>http://nostylesheets.com/2010/04/06/htaccess-redirect-with-a-space-in-the-url/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The jQuery/PHP Validator</title>
		<link>http://nostylesheets.com/2010/04/06/the-jqueryphp-validator/</link>
		<comments>http://nostylesheets.com/2010/04/06/the-jqueryphp-validator/#comments</comments>
		<pubDate>Tue, 06 Apr 2010 13:28:39 +0000</pubDate>
		<dc:creator>Esdras Terrero</dc:creator>
				<category><![CDATA[JS]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://nostylesheets.com/?p=459</guid>
		<description><![CDATA[Check out our demo which uses the jQuery as well as the PHP validator: http://open-source.yes2web.nl/php-validator/demo1/validator-form.php We the developers  already know about the famous jQuery validator and about all the wonderful things it is capable of. But we also know that this validation is only on the client side. What about server side validation on form [...]]]></description>
			<content:encoded><![CDATA[<p>Check out our demo which uses the jQuery as well as the PHP  validator:<br />
<a href="http://open-source.yes2web.nl/php-validator/demo1/validator-form.php" target="_blank"><span style="color: #6fa8dc">http://open-source.yes2web.nl/php-validator/demo1/validator-form.php</span></a></p>
<p>We the developers  already know about the famous <a id="p_nk" title="jQuery validator" href="http://bassistance.de/jquery-plugins/jquery-plugin-validation/" target="_blank">jQuery validator</a> and about all  the wonderful things it is capable of. But we also know that this validation is  only on the client side.</p>
<p>What about server side validation on  form input? Isn&#8217;t that important too? Of course it is. And that is  exactly why we&#8217;ve come up with the following solution for this issue: The php validator. This validator  consists of  a class which contains a collection of methods similar to the  jQuery validator. This way, we have validation on both client- and  server sides using exactly the same rules and error messages.</p>
<p>Our  PHP validator is based on the bassistance jQuery validator found at: <a href="http://bassistance.de/jquery-plugins/jquery-plugin-validation/" target="_blank"><span style="color: #3d85c6">http://bassistance.de/jquery-plugins/jquery-plugin-validation/</span></a></p>
<p><span style="color: #3d85c6"><span id="more-459"></span><br />
</span></p>
<p><strong>How  it works</strong></p>
<p>It&#8217;s pretty simple really. All you need is the  Validator.class.php file which can be found at the google code project  page <a href="http://code.google.com/p/jquery-validation-php-plugin/" target="_blank">http://code.google.com/p/jquery-validation-php-plugin/</a>, or it can  be downloaded directly from: <a href="http://jquery-validation-php-plugin.googlecode.com/files/jquery-validation-php-plugin-0.3.zip" target="_blank"><span>http://jquery-validation-php-plugin.googlecode.com/files/jquery-validation-php-plugin-0.3.zip</span></a>.  Once you obtain this crucial file, then you can get to work.</p>
<p>First,  make an instance by doing the following:</p>
<pre><span style="font-family: 'Courier  New'"><span style="color: #990000">$oValidator</span> = <span style="color: #3d85c6">new</span> Validator(<span style="color: #990000">$aasOption</span>);</span></pre>
<p><strong>The  two-way road: PHP and jQuery</strong><br />
The <span style="font-family: 'Courier New';color: #990000">$</span><span style="font-family: 'Courier New';color: #990000">aasOption</span> variable is an array with our validation rules and messages. This array  is built the same way the jQuery is built. The main advantage of  creating this array is that we can use it in PHP as well as JavaScript.  This is mainly due to the fact that they both use the same atributes:  &#8216;rules&#8217; and &#8216;messages&#8217;. This way, we can implement it both ways.</p>
<p>Here  is a simple example requiring the <span style="font-family: 'Courier New'"><span style="color: #990000">$_POST</span>['name']</span> field to be set:</p>
<p><span style="color: #6fa8dc"><span style="font-family: 'Courier New'">$aasOption = array(</span></span><br />
<span style="color: #6fa8dc"><span style="font-family: 'Courier New'"> &#8216;rules&#8217; =&gt; array(</span></span><br />
<span style="color: #6fa8dc"><span style="font-family: 'Courier New'"> &#8216;name&#8217; =&gt; &#8216;required&#8217;</span></span><br />
<span style="color: #6fa8dc"><span style="font-family: 'Courier New'"> ),</span></span><br />
<span style="color: #6fa8dc"><span style="font-family: 'Courier New'"> &#8216;messages&#8217;  =&gt; array(</span></span><br />
<span style="color: #6fa8dc"><span style="font-family: 'Courier New'"> &#8216;name&#8217; =&gt; array(</span></span><br />
<span style="color: #6fa8dc"><span style="font-family: 'Courier New'"> &#8216;required&#8217; =&gt; &#8216;This field is  required&#8217;</span></span><br />
<span style="color: #6fa8dc"><span style="font-family: 'Courier New'"> )</span></span><br />
<span style="color: #6fa8dc"><span style="font-family: 'Courier New'"> )</span></span><br />
<span style="color: #6fa8dc"><span style="font-family: 'Courier New'"> );</span></span></p>
<p>The following javascript shows how we implement the  array for use in JavaScript:</p>
<div><span style="font-family: 'Courier New'">$(document.forms[0]).validate(<span style="color: #ff0000">&lt;?php</span> json_encode($aasOption); <span style="color: #ff0000">?&gt;</span>);</span></div>
<p>The catch is that each  field to be validated must be specified in the jQuery options object by  it&#8217;s name, not by id or class, as these are not acuired by the server.</p>
<p><strong>The  Form</strong><br />
Now that we can call upon our source, we can build our soon to  be validated form.</p>
<p><span style="font-family: 'Courier New'">&lt;label  for=&#8221;name&#8221;&gt;Name:&lt;/label&gt;<br />
&lt;input id=&#8221;name&#8221; type=&#8221;text&#8221;  name=&#8221;name&#8221; value=&#8221;<span style="color: #ff0000">&lt;?php</span> </span></p>
<div><span style="font-family: 'Courier New'"> echo isset(<span style="color: #990000">$_POST</span>[<span style="color: #6aa84f">'name'</span>])? <span style="color: #990000">$_POST</span>[<span style="color: #6aa84f">'name'</span>]:&#8221;; </span></div>
<p><span style="font-family: 'Courier New'"><span style="color: #ff0000">?&gt;</span>&#8220;/&gt;</span></p>
<p>Now that we have a form, we can validate it with PHP. We must  first check if there&#8217;s an empty <span style="font-family: 'Courier New'">$_POST</span>.<br />
<span style="color: #6fa8dc"> <span style="font-family: courier new">if(!empty($_POST)){} </span></span></p>
<p>It is within this if- statement where validation  is triggered using the validate(); method from the Validator.class.php.</p>
<p>The  if- statement will eventually look like this:</p>
<p><span style="font-family: courier new;color: #6fa8dc"> if(!empty($_POST)){</span><br />
<span style="font-family: courier new;color: #6fa8dc"> $oValidator-&gt;validate($_POST);</span><br />
<span style="font-family: courier new;color: #6fa8dc"> }</span></p>
<p>Now we have validation. Hey! But wait! I don&#8217;t  see any messages.<br />
That is absolutely true because we haven&#8217;t added  them yet.</p>
<p>Next to the input field, we must use the exact same  label tag for errors that you would use in the jQuery validator.<br />
We  do this by using the <span style="font-family: courier new">showError();</span> method, found in the Validator class. We then echo the message by typing  in the following:</p>
<p><span style="font-family: courier new;color: #6fa8dc"><span style="color: #ff0000"> &lt;?php</span> echo  $oValidator-&gt;showError(&#8216;name&#8217;); <span style="color: #ff0000">?&gt;</span></span></p>
<p>Pay  attention: The <span style="font-family: courier new">showError();</span> method  creates a label tag by default. You don&#8217;t have to create a label in wich  you echo the method.</p>
<p>For the the jQuery validation you can go to  work the same way you usually do. The only difference is that you will  use the <span style="font-family: courier new"><span style="color: #990000">$aasOption array</span></span>.  More information about the jQuery validation can be found at:<span style="color: #3d85c6"> <a href="http://bassistance.de/jquery-plugins/jquery-plugin-validation/" target="_blank">http://bassistance.de/jquery-plugins/jquery-plugin-validation/</a></span></p>
<p>Here  is how you refer to it in JavaScript: <span style="font-family: courier new;color: #6fa8dc">validate(<span style="color: #ff0000">&lt;?php</span> echo  json_encode($aasOption);<span style="color: #ff0000">?&gt;</span>);</span></p>
<p>For  your viewing pleasure, we have created a demo so that you can see  both the php and the JavaSript validation in action:<br />
<a href="http://open-source.yes2web.nl/php-validator/demo1/validator-form.php" target="_blank"><span style="color: #6fa8dc">http://open-source.yes2web.nl/php-validator/demo1/validator-form.php</span></a><br />
Further documentation:<br />
<a href="http://bassistance.de/jquery-plugins/jquery-plugin-validation/" target="_blank"><span style="color: #6fa8dc">http://bassistance.de/jquery-plugins/jquery-plugin-validation/</span></a><br />
<a href="http://docs.jquery.com/Plugins/Validation" target="_blank"><span style="color: #6fa8dc">http://docs.jquery.com/Plugins/Validation</span></a><br />
<a href="http://code.google.com/p/jquery-validation-php-plugin/" target="_blank"><span style="color: #6fa8dc">http://code.google.com/p/jquery-validation-php-plugin/</span></a></p>
]]></content:encoded>
			<wfw:commentRss>http://nostylesheets.com/2010/04/06/the-jqueryphp-validator/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Thoughts on php&#8217;s print_r</title>
		<link>http://nostylesheets.com/2010/03/25/thoughts-on-phps-print_r/</link>
		<comments>http://nostylesheets.com/2010/03/25/thoughts-on-phps-print_r/#comments</comments>
		<pubDate>Thu, 25 Mar 2010 11:58:48 +0000</pubDate>
		<dc:creator>gerrit</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://nostylesheets.com/?p=445</guid>
		<description><![CDATA[Just a quick quick question: Why does php&#8217;s print_r function, which is pretty usefull to all, feature a $return (optional) argument? Not a question about it&#8217;s usefulness, but rather the choice to include this into the print_r. I would prefer to see an sprint_r variant behaving like function sprint_r&#40;$sIn&#41;&#123; return print_r&#40;$sIn, true&#41;; &#125; to conform [...]]]></description>
			<content:encoded><![CDATA[<p>Just a quick quick question: Why does php&#8217;s <a href="http://nl3.php.net/manual/en/function.print-r.php" target="_blank">print_r</a> function, which is pretty usefull to all, feature a <code>$return</code> (optional) argument? Not a question about it&#8217;s usefulness, but rather the choice to include this into the print_r. I would prefer to see an <code>sprint_r</code> variant behaving like</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> sprint_r<span style="color: #009900;">&#40;</span><span style="color: #000088;">$sIn</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
     <span style="color: #b1b100;">return</span> <span style="color: #990000;">print_r</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sIn</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>to conform to choices made for (<code>s</code>)<code>printf</code>. While on the subject, why not include a <code>fprint_r</code> as well (useful perhaps for logging):</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> fprint_r<span style="color: #009900;">&#40;</span><span style="color: #000088;">$oFP</span><span style="color: #339933;">,</span> <span style="color: #000088;">$sIn</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
     <span style="color: #b1b100;">return</span> <span style="color: #990000;">fwrite</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$oFP</span><span style="color: #339933;">,</span> sprint_r<span style="color: #009900;">&#40;</span><span style="color: #000088;">$sIn</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>and perhaps a <code>vprint_r</code> to complete the symmetry, though I have no clue as to what it should do <img src='http://nostylesheets.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
]]></content:encoded>
			<wfw:commentRss>http://nostylesheets.com/2010/03/25/thoughts-on-phps-print_r/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Character encoding in MySQL</title>
		<link>http://nostylesheets.com/2010/02/27/character-encoding-in-mysql/</link>
		<comments>http://nostylesheets.com/2010/02/27/character-encoding-in-mysql/#comments</comments>
		<pubDate>Sat, 27 Feb 2010 15:48:22 +0000</pubDate>
		<dc:creator>Jop</dc:creator>
				<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.nostylesheets.com/?p=89</guid>
		<description><![CDATA[Just a quick note on character encoding in MySQL, use the following to force MySQL into using UTF-8 for ever! PHP In your PHP, always use the following immediately after you set up your connection. mysql_set_charset(&#8216;utf8&#8242;, $oDB); mysql_query(&#8216;SET NAMES \&#8217;utf8\&#8221;); The tricky bit lies in your MySQL configuration file: my.cnf Add the following lines: [client] [...]]]></description>
			<content:encoded><![CDATA[<p>Just a quick note on character encoding in MySQL, use the following to force MySQL into using UTF-8 for ever!</p>
<h2>PHP</h2>
<p>In your PHP, always use the following immediately after you set up your connection.</p>
<ul>
<li>mysql_set_charset(&#8216;utf8&#8242;, $oDB);</li>
<li>mysql_query(&#8216;SET NAMES \&#8217;utf8\&#8221;);</li>
</ul>
<p>The tricky bit lies in your MySQL configuration file:</p>
<h2>my.cnf</h2>
<p>Add the following lines:</p>
<pre>[client]
default-character-set=utf8
[mysqld]
default-character-set=utf8
default-collation = utf8_general_ci</pre>
<p>This tells MySQL that the client (which is either PHP or the system) expects UTF-8. If you don&#8217;t tell MySQL this, a mysqldump will produce ANSI and an import from the command line will result in double encodings.</p>
<p>And don&#8217;t forget to use utf8_general_ci for all databases, tables  and fields!</p>
]]></content:encoded>
			<wfw:commentRss>http://nostylesheets.com/2010/02/27/character-encoding-in-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mobile web &#8211; introduction</title>
		<link>http://nostylesheets.com/2009/07/31/mobile-web-introduction/</link>
		<comments>http://nostylesheets.com/2009/07/31/mobile-web-introduction/#comments</comments>
		<pubDate>Fri, 31 Jul 2009 08:20:47 +0000</pubDate>
		<dc:creator>Bernhard</dc:creator>
				<category><![CDATA[Mobile Browsers]]></category>

		<guid isPermaLink="false">http://nostylesheets.com/?p=364</guid>
		<description><![CDATA[I&#8217;m not a marketing specialist, but I can see a lot of things change very quickly when we talk about mobile devices. Since its invention the mobile phone became indispensable in our lives. The mobile phone is used mainly for business purposes, but this is changing day by day: The market is moving fast to [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify">I&#8217;m not a marketing specialist, but I can see a lot of things change very quickly when we talk about mobile devices. Since its invention the mobile phone became indispensable in our lives. The mobile phone is used mainly for business purposes, but this is changing day by day: The market is moving fast to consumers too. With more people using a high-end phone, the capabilities for mobile web design give developers the opportunity to focus on this group of people as well.</p>
<p style="text-align: justify">Many people think it&#8217;s hard to make their website suitable for mobile devices, but this isn&#8217;t the case at all. In this article I&#8217;ll introduce a couple of things you should consider before developing a mobile website. In a future article I&#8217;ll give some hands-on advice on where to start.<span id="more-364"></span></p>
<h2 style="text-align: justify">Know your visitors <img class="size-thumbnail wp-image-375 alignright" src="http://nostylesheets.com/files/2009/07/nokia_1100-150x150.jpg" alt="nokia_1100" width="150" height="150" /></h2>
<p style="text-align: justify">When you consider to build a mobile website you should first question who you want to target. This is first step and very important for the rest of the process. There are thousands of different mobile devices and how much you probably want to target them all, that is pretty ambitious since almost every mobile browser reacts different. Why is this so important? If you want to target a group of people using low-end devices such as the Nokia 1100, which is very popular amongst low-budget users, this has consequences for example in the choice for the right mark-up language (more about this in a follow-up article). Another good example is when you have a b2b (business to business) model, most visitors use a &#8216;Blackberry&#8217;, so your website will have to be compatible with the Blackberry browser.</p>
<h2>Choose your method</h2>
<p style="text-align: justify">
<p style="text-align: justify">There are a couple of methods you can choose from for setting up your mobile environment. One of these methods is &#8216;doing nothing&#8217;. This is the easiest way, but definitely not the best way of dealing with mobile devices. Why is this one of the methods? After reading this article you could decide not to develop a mobile website any longer. I just want to point out that this &#8220;method&#8221; causes unpredictable results rendering your website on a mobile device.</p>
<p style="text-align: justify">The <strong>second</strong> method is to make a mobile version of your CSS stylesheet using &#8216;media=&#8221;handheld&#8221;&#8216;. In many cases this works just fine, but you&#8217;ll run into problems very easily when you test your site in different devices. Although the mediatype &#8216;handheld&#8217; is W3C compliant, it&#8217;s not a general standard. Many mobile browsers have their own way of interpretation of &#8216;media=&#8221;handheld&#8221;&#8216; and therefore  this method is not very reliable. Here you can see the differences in interpretation (source from &#8216;<a href="http://www.alistapart.com/articles/return-of-the-mobile-stylesheet" target="_blank">a list apart</a>&#8216;):</p>
<table id="table-1" border="0" cellspacing="0">
<thead>
<tr>
<th><span class="caps">CSS </span>Behavior</th>
<th>Browsers</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">Reading <strong>only</strong> <code>handheld</code> style sheets</th>
<td>OpenWave browser, Nokia lite-web browsers, Netfront (configuration dependent), Digia, BlackBerry browser, Opera Mini until v4, Opera Mobile until v9</td>
</tr>
<tr>
<th scope="row">Reading <strong>both</strong> <code>handheld</code> and <code>screen</code> style sheets</th>
<td>Palm’s Blazer, Nokia <span class="caps">S40</span> browser, IEMobile 6.x and 8.x</td>
</tr>
<tr>
<th scope="row">Reading only <code>screen</code> style sheets <strong>with Media Query support</strong></th>
<td>iPhone’s Safari, Opera Mobile starting v9, Opera Mini starting v4</td>
</tr>
<tr>
<th scope="row">Reading only <code>screen</code> style sheets without Media Query support</th>
<td>Nokia <span class="caps">S60</span> browser, Netfront (configuration dependant), Teleqa Q7, IEMobile 7.x</td>
</tr>
</tbody>
</table>
<p style="text-align: justify">A <strong>third</strong> method you could use is to let your server determine which user agent your visitor is using and showing him the right version of your website. This method gives you the opportunity to build multiple versions, for multiple platforms, without using an alternative url. Your visitor can easily find you on your normal url (www.mybrand.com) instead of an alternative (www.mybrand-mobile.com). The problem with this method is that you can never let your visitor decide which version of your website he wants to see. He can&#8217;t switch between your versions if he thinks your pc version is better on his device.</p>
<p style="text-align: justify">The last method is related to the third method. It is possible to use build your own mobile version of your website with another url without losing your brand name. Examples: www.mybrand.com/mobile or mobile.mybrand.com or even shorter: m.mybrand.com.  In this case you can give your visitor the opportunity to switch from you mobile version to your standard version, so for flexibility reasons this method could be the best way. It is also possible to registrate an .mobi TLD (Top Level Domain), for example your url looks like: www.mybrand.mobi.</p>
<p style="text-align: justify">In my opinion the last method is the best way to achieve your goals. With a mobile version next to your normal site you can also optimize your mobile content. My preferences is to take the .mobi domain name, which could quickly evolve into the standard, when everyone uses a different way it will be still difficult to find the mobile version.</p>
<p style="text-align: justify">You can always choose or combine methods to suit your preferences. Keep your focus on your target group of visitors and be aware of the restrictions on many mobile devices.</p>
<h2 style="text-align: justify">The importance of testing</h2>
<p style="text-align: justify">Although this is a step you take after realising your mobile website, testing is an important component of the process.  You have to  think about validating/ testing before you can put your site online! Mobile browsers, in contrast to the browser on your pc, are very strict in reading your code. Make sure you validate your xHTML (<a id="au:i" title="validate" href="http://validator.w3.org/">validate</a> / <a id="rfeo" title="mobilevalidate" href="http://validator.w3.org/mobile/">mobilevalidate</a>) or WML (<a id="o_8a" title="validate" href="http://www.w3schools.com/wap/wml_validate.asp">validate</a>). Another way to check the mobile browser compatibility can be found <a href="http://www.vladimirpetkovic.com/blog/mobile-browser-compatibility-test/" target="_blank">here</a> or <a href="http://ready.mobi/" target="_blank">here</a>.</p>
<p style="text-align: justify">Last but not least you have to test your websites. This can be difficult if you are not in possession of the right equipment. Let me point out a few possibilities to test your mobile website.</p>
<p style="text-align: justify">Test your mobile website on an emulator. This is the most common way to test your website in the first place. It is also not the easiest one. Finding a good emulator isn&#8217;t easy since the most look more like a simulator. Well known emulators are from <a id="vs8q" title="dotMobi" href="http://emulator.mtld.mobi/emulator.php?emulator=nokiaN70&amp;webaddress=mtld.mobi">dotMobi</a>, <a id="dfuo" title="Openwave" href="http://developer.openwave.com/dvl/tools_and_sdk/phone_simulator/">Openwave</a> and <a id="csz4" title="Apple" href="http://developer.apple.com/iphone/">Apple</a>. Problem with the most emulators is that they interpret the user agent like a normal browser (browser on the machine where the emulator is installed). This makes it hard to test and you can&#8217;t rely 100% on what you see.</p>
<p style="text-align: justify">The most expensive way of testing is to buy a small subset or representative phones. This is more an option if you&#8217;re considering to develop more mobile websites in the near future. Make sure you select a combination of different browsers on different devices (Windows Mobile Explorer, Safari Mobile, Opera Mini and Nokia&#8217;s built in browser).</p>
<p style="text-align: justify">Another way is to ask your friends or colleagues to test your website on their mobile phones. There is always someone to help you out. Make sure your code is valid first and that you have tested it in an emulator, so that you can do your testing on you friends phone quickly and effective.</p>
]]></content:encoded>
			<wfw:commentRss>http://nostylesheets.com/2009/07/31/mobile-web-introduction/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
