<?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"
	>

<channel>
	<title>WeBubble</title>
	<atom:link href="http://www.webubble.co.uk/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.webubble.co.uk</link>
	<description>The ramblings of a Coding MadMan</description>
	<pubDate>Sat, 27 Sep 2008 12:09:40 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5</generator>
	<language>en</language>
			<item>
		<title>SEO URL&#8217;s 404 Alternative</title>
		<link>http://www.webubble.co.uk/2008/04/02/seo-urls-404-alternative/</link>
		<comments>http://www.webubble.co.uk/2008/04/02/seo-urls-404-alternative/#comments</comments>
		<pubDate>Wed, 02 Apr 2008 17:27:04 +0000</pubDate>
		<dc:creator>Jez</dc:creator>
		
		<category><![CDATA[Apache]]></category>

		<category><![CDATA[Htaccess]]></category>

		<category><![CDATA[SEO]]></category>

		<category><![CDATA[404]]></category>

		<category><![CDATA[empty post data]]></category>

		<category><![CDATA[Errordocument]]></category>

		<category><![CDATA[rewrite]]></category>

		<category><![CDATA[SEO Url's]]></category>

		<guid isPermaLink="false">http://www.webubble.co.uk/?p=6</guid>
		<description><![CDATA[Many websites using search engine optimised URL's require a single point of entry and for this they use the Apache ErrorDocument 404 call. This means every page is redirected to a control page which can then analyse the URI Request and decide which page to load.]]></description>
			<content:encoded><![CDATA[<p>Many websites using search engine optimised URL&#8217;s require a single point of entry and for this they use the Apache ErrorDocument 404 call. This means every page is redirected to a control page which can then analyse the URI Request and decide which page to load.</p>
<p><span id="more-6"></span></p>
<p>In my experience with this technique I have come across numerous problems, mainly that the form POST method will not work. After research it appears this is because the data is being redirected to a 404 error, so the information is lost. For most people this isn&#8217;t a problem, as they can use separate pages which exist to analyse the form data, however this defeats the object of keeping the single point of entry for the website.</p>
<p>A solution to this problem is using the RewriteEngine, we can rewrite every requested URL to the entry script.</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">Options +FollowSymLinks
</div>
</li>
<li class="li1">
<div class="de1">RewriteEngine on
</div>
</li>
<li class="li1">
<div class="de1">RewriteBase /
</div>
</li>
<li class="li1">
<div class="de1">RewriteRule ^(.*)$ index.php</div>
</li>
</ol>
</div>
<p>This will effectively rewrite every request to &#8220;index.php&#8221; no matter what file it is, which obviously isn&#8217;t good if we want to be able to load images and css files into the page. A simple way to achieve this, is with some RewriteConditions.</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">Options +FollowSymLinks
</div>
</li>
<li class="li1">
<div class="de1">RewriteEngine on
</div>
</li>
<li class="li1">
<div class="de1">RewriteBase /
</div>
</li>
<li class="li1">
<div class="de1">RewriteCond %{REQUEST_URI} !images(.*)$
</div>
</li>
<li class="li2">
<div class="de2">RewriteCond %{REQUEST_URI} !css(.*)$
</div>
</li>
<li class="li1">
<div class="de1">RewriteCond %{REQUEST_URI} !js(.*)$
</div>
</li>
<li class="li1">
<div class="de1">RewriteRule ^(.*)$ index.php</div>
</li>
</ol>
</div>
<p>As you can see this will check if the words images, css or js exist within the requested URI. This is great, however everytime we want to exclude a page or directory from our script we will have to add an exception to the htaccess file. Luckily apache gives us a wonderful feature to check if the file actually exists on the local filesystem.</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">RewriteEngine On
</div>
</li>
<li class="li1">
<div class="de1">RewriteBase /
</div>
</li>
<li class="li1">
<div class="de1">RewriteCond %{SCRIPT_FILENAME} !-f
</div>
</li>
<li class="li1">
<div class="de1">RewriteCond %{SCRIPT_FILENAME} !-d
</div>
</li>
<li class="li2">
<div class="de2">RewriteRule ^(.*)$ index.php</div>
</li>
</ol>
</div>
<p>The -f means the filename, so by checking if it exists within the requested script filename we can decide whether or not to include our base handler script. The &#8220;!&#8221; simply means &#8220;not&#8221; so if the file doesnt exist continue with the conditions, where as if it does exist, load that file instead. The next line (&#8221;-d&#8221;) means check if the directory path exists and if so, load that rather than calling the handling script.</p>
<p>Thats all there is to it, and now form data can be posted backwards and forwards without any issues!</p>

]]></content:encoded>
			<wfw:commentRss>http://www.webubble.co.uk/2008/04/02/seo-urls-404-alternative/feed/</wfw:commentRss>
		</item>
		<item>
		<title>PHP For the Road: Part 1</title>
		<link>http://www.webubble.co.uk/2008/03/29/php-for-the-road-part-1/</link>
		<comments>http://www.webubble.co.uk/2008/03/29/php-for-the-road-part-1/#comments</comments>
		<pubDate>Sat, 29 Mar 2008 21:30:26 +0000</pubDate>
		<dc:creator>Jez</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<category><![CDATA[PHP For The Road]]></category>

		<category><![CDATA[Beginner]]></category>

		<category><![CDATA[Shortcuts]]></category>

		<category><![CDATA[Strings]]></category>

		<guid isPermaLink="false">http://www.webubble.co.uk/?p=5</guid>
		<description><![CDATA[I have decided to start a series on PHP Tips and Tricks, and I may even throw in a few other bits and bobs that I have come across. To start with, I'm going to be covering PHP shortcuts that every beginner should know (I didn't find these out until much later in my PHP experience!)  and a few other tidbits.]]></description>
			<content:encoded><![CDATA[<p>I have decided to start a series on PHP Tips and Tricks, and I may even throw in a few other bits and bobs that I have come across. To start with, I&#8217;m going to be covering PHP shortcuts that every beginner should know (I didn&#8217;t find these out until much later in my PHP experience!)  and a few other tidbits.</p>
<p><span id="more-5"></span></p>
<p>One of the more common tasks in PHP is printing an array item or variable out within a string of html. There are many ways of doing this, to see a full listing, visit <a href="http://www.php.net/string">php.net/string</a>. I&#8217;m going to be focusing on a few shortcuts which don&#8217;t get mentioned very much and are often taken for granted.</p>
<p>The first method is using curly braces:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><span class="kw2">&lt;?</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$foo</span> = <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><span class="st0">&quot;Hello&quot;</span>, <span class="st0">&quot;World&quot;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <span class="st0">&quot;{$foo[&#8217;0&#8242;]}, {$foo[&#8217;1&#8242;]}&quot;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="co1">//output: Hello, World</span></div>
</li>
<li class="li2">
<div class="de2"><span class="kw2">?&gt;</span></div>
</li>
</ol>
</div>
<p>Alternatives to this would be to use string concatenation such as below:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">&lt;?<span class="re0">$foo</span> = <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><span class="st0">&quot;Hello&quot;</span>, <span class="st0">&quot;World&quot;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <span class="re0">$foo</span><span class="br0">&#91;</span><span class="st0">&#8216;0&#8242;</span><span class="br0">&#93;</span>.<span class="st0">&quot;, &quot;</span>.<span class="re0">$foo</span><span class="br0">&#91;</span><span class="st0">&#8216;1&#8242;</span><span class="br0">&#93;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="co1">//output: Hello, World</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">?&gt;</span></div>
</li>
</ol>
</div>
<p>However, this method does involve a whole extra 2 characters to type! but it provides memory benefits over parsing the variables directly in the string.</p>
<p>A quick way for just printing a variable in an HTML segment is to use the = operator after the php open tags followed by the variable and then close the tags again. For example:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><span class="kw2">&lt;?</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$foo</span> = <span class="st0">&quot;Hello World&quot;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">?&gt;</span></div>
</li>
<li class="li1">
<div class="de1">&lt;h1&gt;&lt;?=<span class="re0">$foo</span>?&gt;&lt;/h1&gt;</div>
</li>
<li class="li2">
<div class="de2">&lt;p&gt;Lots of html text and declarations here&lt;/p&gt;</div>
</li>
</ol>
</div>
<p>Another alternative is using echo&#8217;s multiple parameters which is slightly faster than string concatenation. When passing parameters to echo a &#8216;,&#8217; can be used to separate the variables and strings, and the echo function will display it as if it had been created any other way.</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><span class="kw2">&lt;?</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$foo</span> = <span class="st0">&quot;Hello&quot;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$bar</span> = <span class="st0">&quot;World&quot;</span>;</div>
</li>
<li class="li1">
<div class="de1"><a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <span class="re0">$foo</span>,<span class="st0">&quot;, &quot;</span>, <span class="re0">$bar</span>;</div>
</li>
<li class="li2">
<div class="de2"><span class="co1">//output: Hello, World</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">?&gt;</span></div>
</li>
</ol>
</div>
<p>As PHP has such a vast library of built in functions, you can never know if something exists for what you want, or if you have to make it yourself. I stumbled across a few which I never would have though existed.</p>
<blockquote><p>1. <a href="http://www.php.net/get_meta_tags">get_meta_tags($file)</a></p></blockquote>
<p>This function basically retrieves an array of all of the meta tags within the included file. I came across this when looking into how to extract some custom meta data from a template system.</p>
<blockquote><p>2. <a href="http://www.php.net/file_exists">file_exists($file)</a></p></blockquote>
<p>File_exists is a more common function, however its still valuable and can be overlooked if your creating a system demanding a lot of external resources.</p>
<blockquote><p>3. <a href="http://www.php.net/get_defined_vars">get_defined_vars()</a></p></blockquote>
<p>If you have ever written such a large script that you cant remember what is declared where, a useful function is get_defined_vars. It will output all of the currently defined and accessible variables in a multi-dimensional array.</p>
<p>That&#8217;s it for Part 1, hopefully you have found something useful out of that, I&#8217;m hoping Part 2 might cover some more complex PHP ideas, if you have any requests please feel free to leave a comment!</p>

]]></content:encoded>
			<wfw:commentRss>http://www.webubble.co.uk/2008/03/29/php-for-the-road-part-1/feed/</wfw:commentRss>
		</item>
		<item>
		<title>MySQL Tables and Tribulations</title>
		<link>http://www.webubble.co.uk/2008/03/29/mysql-tables-and-tribulations/</link>
		<comments>http://www.webubble.co.uk/2008/03/29/mysql-tables-and-tribulations/#comments</comments>
		<pubDate>Sat, 29 Mar 2008 14:11:21 +0000</pubDate>
		<dc:creator>Jez</dc:creator>
		
		<category><![CDATA[MySQL]]></category>

		<category><![CDATA[Queries]]></category>

		<category><![CDATA[Accidental Table]]></category>

		<guid isPermaLink="false">http://www.webubble.co.uk/1999/11/30/mysql-tables-and-tribulations/</guid>
		<description><![CDATA[Whilst working on a database query for part of my project, I had to join a few tables in a query. It was nothing out of the ordinary, however after some alterations and debugging later, I found out the query execution time took over 2 seconds! This was incredibly worrying, so I started performing some immense debugging and I couldn't for the life of me figure out why this query should be executing to slowly.]]></description>
			<content:encoded><![CDATA[<p>Whilst working on a database query for part of my project, I had to join a few tables in a query. It was nothing out of the ordinary, however after some alterations and debugging later, I found out the query execution time took over 2 seconds! This was incredibly worrying, so I started performing some immense debugging and I couldn&#8217;t for the life of me figure out why this query should be executing to slowly.</p>
<p><span id="more-4"></span><br />
The problem I later found out was hiding in plain site, I had completely over looked a table which was left in the select from part of the query which wasn&#8217;t called anywhere.</p>
<p>I was amazed afterwards that leaving a table in there by accident would cause such a massive slow down, the execution time went from 2.02s to 0.06s. However on reflection I assume MySQL is pulling all the info from the specified table and as it contained a lot of rows I imagine added a fairly large overhead on the database. My original query looked similar to:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><span class="kw1">SELECT</span> table1.*, table2.image <span class="kw1">FROM</span> table1, table2, table3, table4 <span class="kw1">WHERE</span> table1.id = table2.table1id <span class="kw1">AND</span> table1.id = table3.table1id <span class="kw1">AND</span> <span class="br0">&#40;</span> <span class="br0">&#40;</span>table3.value=<span class="st0">&#8216;value1&#8242;</span> <span class="kw1">AND</span> table3.value2 = <span class="st0">&#8216;value2&#8242;</span><span class="br0">&#41;</span> <span class="kw1">OR</span> <span class="br0">&#40;</span>table3.value=<span class="st0">&#8216;genericvalue&#8217;</span><span class="br0">&#41;</span><span class="br0">&#41;</span></div>
</li>
</ol>
</div>
<p>As can be seen from this, table4 is not called anywhere in the statement, causing all sorts of havoc. So if your getting slow queries and it doesn&#8217;t make sense, be sure to check that you haven&#8217;t accidentally included an extra table!</p>

]]></content:encoded>
			<wfw:commentRss>http://www.webubble.co.uk/2008/03/29/mysql-tables-and-tribulations/feed/</wfw:commentRss>
		</item>
		<item>
		<title>My first foray into the world of blogging - Windows Live Writer</title>
		<link>http://www.webubble.co.uk/2008/03/28/my-first-foray-into-the-world-of-blogging-windows-live-writer/</link>
		<comments>http://www.webubble.co.uk/2008/03/28/my-first-foray-into-the-world-of-blogging-windows-live-writer/#comments</comments>
		<pubDate>Fri, 28 Mar 2008 18:03:23 +0000</pubDate>
		<dc:creator>Jez</dc:creator>
		
		<category><![CDATA[Blogging Apps]]></category>

		<category><![CDATA[Live Writer]]></category>

		<category><![CDATA[Windows Live]]></category>

		<category><![CDATA[Windows Live Writer]]></category>

		<category><![CDATA[Wizards]]></category>

		<guid isPermaLink="false">http://www.webubble.co.uk/?p=3</guid>
		<description><![CDATA[I plan on sharing my experiences predominantly from a development point of view on a few projects I'm currently working on. I work on developing some medium-ish e-commerce sites using everyone's favourite PHP and MySQL combo. I hope to leave a few coding tips that I have picked up along the way and rant about any annoyances I come across as well. To get me started, i share the wonders and not so wonders of Windows Live Writer (Blogging Tool).]]></description>
			<content:encoded><![CDATA[<p>I plan on sharing my experiences predominantly from a development point of view on a few projects I&#8217;m currently working on. I develop some medium-ish e-commerce sites using everyone&#8217;s favourite PHP and MySQL combo. I hope to leave a few coding tips that I have picked up along the way and rant about any annoyances I come across as well. To get me started, I share the wonders and not so wonders of Windows Live Writer (Blogging Tool).</p>
<p><span id="more-3"></span></p>
<p>First off, my friend over at <a href="http://officedays.webubble.co.uk">Office Days</a> introduced me to <a href="http://get.live.com/writer/overview">Windows Live Writer</a>. I was some what skeptical at first, especially with Microsoft&#8217;s recent history of trying to force themselves into the social networking scene, however it came highly recommended, so I thought I would give it a try. The first time I tried to install it, I was prompted with a &#8220;lovely&#8221; windows live installer, giving me the options to install all sorts of <span style="text-decoration: line-through;">crap</span> wonderful live products. However I was only interested in blogging from an application rather than having to use a web based admin panel, so I let the installation commence. It told me it was installing the Live Writer, so I went off to get a coffee and let it get on with doing its business. To my somewhat not surprise I came back to see that it had failed to install Live Writer, a nice big red X was placed next to the item, and a link to click for more help. The link was about as useful as most Microsoft Live help, telling me to make sure I&#8217;m connected to the Internet and that I don&#8217;t have Windows Firewall blocking the application.</p>
<p>Being the idiot that I am, I thought why not just try to install it again? So I did, this time, I got a wonderful message during install saying &#8220;<em>Sorry this is taking longer than expected, please bear with us</em>&#8220;. I have to give them an A+ for courtesy, but it just makes me wonder why can&#8217;t they just provide an installer that works? Like the message said it did take a long time to do anything with the bar going backwards and forwards and eventually coming to some sort of conclusion. My idiocy had paid off, it appears to have installed fine! Thus proving at first if you don&#8217;t succeed, just try again.</p>
<p>Closing the installation wizard (reminds me more of Rincewind) Windows Live Writer booted up, and I was presented with another &#8220;Getting Started Wizard&#8221;, so with intrepid fingers, I clicked on through the options of providing my existing blog information, URL, username, password, the usual bits. It once again tried to do something, however this time it was much faster, and to my amazement, it had found all of my blog information (<a href="http://www.wordpress.org">WordPress</a>) and was all setup ready to go! A wonderful white page was shown to me, with the standard Windows Live style bars and helpers around the edge. It feels very much like Word, with spell checking, the ability to save drafts, all of the standard blogging and html buttons and shortcuts are also available. So far after writing this post, it seems to work nicely with WordPress, and hopefully I will continue to use it as a worthy alternative to blogging via the WordPress back end.</p>

]]></content:encoded>
			<wfw:commentRss>http://www.webubble.co.uk/2008/03/28/my-first-foray-into-the-world-of-blogging-windows-live-writer/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.434 seconds -->
