<?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>Tue, 05 Apr 2011 09:46:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<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>1000<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>
		<item>
		<title>__PHP_Incomplete_Class Object</title>
		<link>http://nostylesheets.com/2009/07/21/__php_incomplete_class-object/</link>
		<comments>http://nostylesheets.com/2009/07/21/__php_incomplete_class-object/#comments</comments>
		<pubDate>Tue, 21 Jul 2009 08:42:58 +0000</pubDate>
		<dc:creator>gerrit</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://nostylesheets.com/?p=368</guid>
		<description><![CDATA[Just a quick note, as I could not find a satisfactory answer fast enough googling the web. I got a (not so) nice __PHP_Incomplete_Class Object notice the other day, happily programming until that moment. Such a notice indicates that somewhere (very likely in your session) a class has been unserialized that php does not know how [...]]]></description>
			<content:encoded><![CDATA[<p>Just a quick note, as I could not find a satisfactory answer fast enough googling the web. I got a (not so) nice __PHP_Incomplete_Class Object notice the other day, happily programming until that moment. Such a notice indicates that somewhere (very likely in your session) a class has been unserialized that php does not know how to handle. This means that php knows which class the unserialized data should be, but cannot find the class declaration. It may happen using this type of code:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">session_start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">class</span> SomeClass <span style="color: #009900;">&#123;</span> <span style="color: #339933;">...</span> <span style="color: #009900;">&#125;</span>
<span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'some_instance'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// which is a SomeClass assigned in some previous request</span></pre></div></div>

<p>Depending on the implementation of the class, e.g. use of SPL, this will result in a __PHP_Incomplete_Class Object. To fix this, tell php what the class is/can do before unserializing, i.e. move <code>session_start</code> below the class declaration.</p>
]]></content:encoded>
			<wfw:commentRss>http://nostylesheets.com/2009/07/21/__php_incomplete_class-object/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>MySQL Substr count</title>
		<link>http://nostylesheets.com/2009/07/17/mysql-substr-count/</link>
		<comments>http://nostylesheets.com/2009/07/17/mysql-substr-count/#comments</comments>
		<pubDate>Fri, 17 Jul 2009 07:21:51 +0000</pubDate>
		<dc:creator>rick</dc:creator>
				<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://nostylesheets.com/?p=337</guid>
		<description><![CDATA[Recently I needed to create an SQL statement which was to count the occurences of a character inside a particular database field. For example, you could store the tags connected to a single db-record in a semi-colon (;) separated column in the record. To get the number of tags for this record straight from the database, we would thus like the number of semi-colons in the field (+1) as an indicator for this count. Since <a href="http://dev.mysql.com/doc/refman/5.0/en/string-functions.html">MySQL5 does not have a standard function</a> for this (similar to PHP's <code>substr_count()</code>), I had to find something of my own. ]]></description>
			<content:encoded><![CDATA[<p>Recently I needed to create an SQL statement which was to count the occurences of a character inside a particular database field. For example, you could store the tags connected to a single db-record in a semi-colon (;) separated column in the record. To get the number of tags for this record straight from the database, we would thus like the number of semi-colons in the field (+1) as an indicator for this count. Since <a href="http://dev.mysql.com/doc/refman/5.0/en/string-functions.html">MySQL5 does not have a standard function</a> for this (similar to PHP&#8217;s <a title="PHP substr_count" href="http://www.php.net/substr_count">substr_count()</a>), I had to find something of my own. <span id="more-337"></span></p>
<p>I found the following nifty solution floating around several forums:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">SELECT</span>
    <span style="color: #66cc66;">&#40;</span>LENGTH<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">`_field_`</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">-</span> LENGTH<span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">REPLACE</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">`_field_`</span><span style="color: #66cc66;">,</span><span style="color: #ff0000;">&quot;_substr_&quot;</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">/</span> LENGTH<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;_substr_&quot;</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #993333; font-weight: bold;">AS</span> <span style="color: #ff0000;">&quot;iCount&quot;</span>
<span style="color: #993333; font-weight: bold;">FROM</span> <span style="color: #66cc66;">...</span></pre></div></div>

<p>The trick is straightforward: just remove your separator from the field-contents and see how much smaller the resulting value is compared to the original. Divide this by the length of your separator if it is composed of more than one character. I recommend replacing <code>LENGTH("_substr_")</code> by a number, as you generally know the length of the separator. Leave the division out when using a single length separator:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;">    <span style="color: #66cc66;">&#40;</span>LENGTH<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">`_field_`</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">-</span>LENGTH<span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">REPLACE</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">`_field_`</span><span style="color: #66cc66;">,</span><span style="color: #ff0000;">&quot;_substr_&quot;</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>This method may seem a little brute, but it reportedly not as slow as you might think (though I have not benchmarked it).</p>
]]></content:encoded>
			<wfw:commentRss>http://nostylesheets.com/2009/07/17/mysql-substr-count/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

