<?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>David Parkinson - Miscellaneous ramblings of a web developer &#187; Web Development</title>
	<atom:link href="http://daparky.com/category/web-development/feed/" rel="self" type="application/rss+xml" />
	<link>http://daparky.com</link>
	<description>Miscellaneous ramblings of a web developer called David Parkinson. I work full time as a web developer but have interests in other things.</description>
	<lastBuildDate>Mon, 14 May 2012 20:57:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Codeigniter Vanity / Username / Personalised URL&#8217;s</title>
		<link>http://daparky.com/codeigniter-vanity-username-personalised-urls/</link>
		<comments>http://daparky.com/codeigniter-vanity-username-personalised-urls/#comments</comments>
		<pubDate>Mon, 14 May 2012 20:47:28 +0000</pubDate>
		<dc:creator>David Parkinson</dc:creator>
				<category><![CDATA[Codeigniter]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://daparky.com/?p=505</guid>
		<description><![CDATA[Vanity URL&#8217;s are best described as a personalised URL, for example if you want to create a website where a user has their own space, e.g. example.com/username. Companies use this method to advertise a specific product as it&#8217;s easy to remember and more to the point. I decided to give the a whirl in Codeigniter [...]]]></description>
			<content:encoded><![CDATA[<p>Vanity URL&#8217;s are best described as a personalised URL, for example if you want to create a website where a user has their own space, e.g. example.com/username. Companies use this method to advertise a specific product as it&#8217;s easy to remember and more to the point.</p>
<p>I decided to give the a whirl in Codeigniter which out of the box does not allow this to happen because of the MVC pattern.</p>
<p>If you want vanity url&#8217;s in Codeigniter you have a couple of choices. They both involve URI Routing if you open that file (application/config/routes.php) and paste the following code in:</p>
<pre class="brush: php">
// if you are using modules
if($handle = opendir(APPPATH.&#039;/modules&#039;))
{
while(false !== ($module = readdir($handle)))
{
if($module != &#039;.&#039; &amp;&amp; $module != &#039;..&#039;)
{
$route[$module] = $module;
$route[$module.&#039;/(:any)&#039;] = $module.&#039;/$1&#039;;
}
}
closedir($handle);
}

// if you are using standard MVC
if($handle = opendir(APPPATH.&#039;/controllers&#039;))
{
while(false !== ($controller = readdir($handle)))
{
if($controller != &#039;.&#039; &amp;&amp; $controller != &#039;..&#039; &amp;&amp; strstr($controller, &#039;.&#039;) == &#039;.php&#039;)
{
$route[strstr($controller, &#039;.&#039;, true)] = strstr($controller, &#039;.&#039;, true);
$route[strstr($controller, &#039;.&#039;, true).&#039;/(:any)&#039;] = strstr($controller, &#039;.&#039;, true).&#039;/$1&#039;;
}
}
closedir($handle);
}

// these are the /username routes
$route[&#039;([a-zA-Z0-9_-]+)&#039;] = &#039;controller/index/$1&#039;;
$route[&#039;([a-zA-Z0-9_-]+)/subpage&#039;] = &#039;controller/subpage/$1&#039;;
</pre>
<p>Then in a controller you would have:</p>
<pre class="brush: php">

function index($username = &#039;&#039;)
{
echo $username;
}

function subpage($username = &#039;&#039;)
{
echo $username.&#039; subpage&#039;;
}
</pre>
<p>The other method is very similar, just a different way of achieving it in URI Routing:</p>
<pre class="brush: php">

// modules
if($handle = opendir(APPPATH.&#039;/modules&#039;))
{
while(false !== ($module = readdir($handle)))
{
if($module != &#039;.&#039; &amp;&amp; $module != &#039;..&#039;)
{
$controllers[] = $module;
}
}
closedir($handle);
}

// controllers
if($handle = opendir(APPPATH.&#039;/controllers&#039;))
{
while(false !== ($controller = readdir($handle)))
{
if($controller != &#039;.&#039; &amp;&amp; $controller != &#039;..&#039; &amp;&amp; strstr($controller, &#039;.&#039;) == &#039;.php&#039;)
{
$controllers[] = strstr($controller, &#039;.&#039;, true);
}
}
closedir($handle);
}

$url_parts = explode(&#039;/&#039;,$_SERVER[&#039;REQUEST_URI&#039;]);
$reserved_routes = $controllers;

// these are the /username routes
if( ! in_array($url_parts[1], $reserved_routes))
{
$route[&#039;([a-zA-Z0-9_-]+)&#039;] = &#039;controller/index/$1&#039;;
$route[&#039;([a-zA-Z0-9_-]+)/subpage&#039;] = &#039;controller/subpage/$1&#039;;
}
</pre>
<p>Obviously if you aren&#8217;t using modules you can remove the modules code and vice versa.</p>
<p>Hope it helps.</p>
<img src="http://daparky.com/?ak_action=api_record_view&id=505&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://daparky.com/codeigniter-vanity-username-personalised-urls/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP 5.4 Shorter Array Syntax</title>
		<link>http://daparky.com/php-5-4-shorter-array-syntax/</link>
		<comments>http://daparky.com/php-5-4-shorter-array-syntax/#comments</comments>
		<pubDate>Mon, 16 Apr 2012 21:21:19 +0000</pubDate>
		<dc:creator>David Parkinson</dc:creator>
				<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://daparky.com/?p=501</guid>
		<description><![CDATA[I use PHP pretty much every single day from an in house content management system, to WordPress to Zencart and bespoke stuff. I&#8217;ve been keeping a close eye on the latest PHP developments and i&#8217;m so glad they have implemented Javascript&#8217;s syntax for handling arrays. You did simple arrays the old way like this:- $array [...]]]></description>
			<content:encoded><![CDATA[<p>I use PHP pretty much every single day from an in house content management system, to WordPress to Zencart and bespoke stuff. I&#8217;ve been keeping a close eye on the latest PHP developments and i&#8217;m so glad they have implemented Javascript&#8217;s syntax for handling arrays.</p>
<p>You did simple arrays the old way like this:-</p>
<pre class="brush: php">

$array = array(
&quot;foo&quot; =&gt; &quot;bar&quot;,
&quot;bar&quot; =&gt; &quot;foo&quot;,
);
</pre>
<p>The new way you do it like this:-</p>
<pre class="brush: php">

$array = [
&quot;foo&quot; =&gt; &quot;bar&quot;,
&quot;bar&quot; =&gt; &quot;foo&quot;,
];
</pre>
<p>You can do arrays without key like this:-</p>
<pre class="brush: php">

$array = [&#039;foo&#039;, &#039;bar&#039;];
</pre>
<p>The old way still works and always will do. For me it just makes sense to do it the new way as it will keep your code looking alot cleaner.</p>
<img src="http://daparky.com/?ak_action=api_record_view&id=501&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://daparky.com/php-5-4-shorter-array-syntax/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Redirect http to https htaccess apache</title>
		<link>http://daparky.com/redirect-http-to-https-htaccess-apache/</link>
		<comments>http://daparky.com/redirect-http-to-https-htaccess-apache/#comments</comments>
		<pubDate>Sat, 28 May 2011 15:59:57 +0000</pubDate>
		<dc:creator>David Parkinson</dc:creator>
				<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://daparky.com/?p=469</guid>
		<description><![CDATA[Are you wondering how to redirect to SSL via htaccess? Alot of users won&#8217;t type in the https or even http for that matter so if your site has an SSL certificate you will want to make sure your visitors get redirected to the secured site. This is very useful for websites with a secure [...]]]></description>
			<content:encoded><![CDATA[<p>Are you wondering how to redirect to SSL via htaccess? Alot of users won&#8217;t type in the https or even http for that matter so if your site has an SSL certificate you will want to make sure your visitors get redirected to the secured site. This is very useful for websites with a secure layer. I will explain in this post exactly how to achieve this.</p>
<p>Presuming you have an Apache server, first off you will need to create a .htaccess file and put the following code in:-</p>
<pre class="brush: php">
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
</pre>
<p>What does the above code do? The first lines tells Apache that we want to use the mod_rewrite module, the second line checks whether HTTPS is off, the third line forces https.</p>
<p>Once you are happy simply upload the file to the root directory of your website.</p>
<p>I hope this helps some of you out there.</p>
<img src="http://daparky.com/?ak_action=api_record_view&id=469&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://daparky.com/redirect-http-to-https-htaccess-apache/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Alternate row colour in PHP</title>
		<link>http://daparky.com/alternate-row-colour-in-php/</link>
		<comments>http://daparky.com/alternate-row-colour-in-php/#comments</comments>
		<pubDate>Tue, 09 Feb 2010 22:23:28 +0000</pubDate>
		<dc:creator>David Parkinson</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://daparky.com/?p=411</guid>
		<description><![CDATA[Over the past couple of months I&#8217;ve been developing a content management system to give myself something to aim for and achieve. What I do with the system is unknown, maybe I&#8217;ll start using it at work. Anyway, I&#8217;ve been posting some stuff on here that I may find userful for other developers, whether they [...]]]></description>
			<content:encoded><![CDATA[<p>Over the past couple of months I&#8217;ve been developing a content management system to give myself something to aim for and achieve. What I do with the system is unknown, maybe I&#8217;ll start using it at work.</p>
<p>Anyway, I&#8217;ve been posting some stuff on here that I may find userful for other developers, whether they know how or not. I wanted to do some alternative row colour for some table results within the system and this is what I did.</p>
<p>Presuming you have a counter such as $i, try this:</p>
<pre class="brush: php">
$i = 0;
foreach($vars as $var) {
$i++;

if($i%2 == 0) { echo &#039;class=&quot;first&quot;&#039;; } else { echo &#039;class=&quot;second&quot;&#039;; }
</pre>
<p>On the first row it will add the class &#8216;first&#8217; and on the second row it will add &#8216;second&#8217;. It will keep repeating this until the last row.</p>
<p>In simple english: The variable $i is 0 before the foreach loop, we check if the variable is divided by 2, we will see if it is odd or even. If it divides, the remainder will be 0, and the classes will echo.</p>
<img src="http://daparky.com/?ak_action=api_record_view&id=411&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://daparky.com/alternate-row-colour-in-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Exiting a foreach loop in PHP</title>
		<link>http://daparky.com/exiting-a-foreach-loop-in-php/</link>
		<comments>http://daparky.com/exiting-a-foreach-loop-in-php/#comments</comments>
		<pubDate>Thu, 10 Dec 2009 19:21:49 +0000</pubDate>
		<dc:creator>David Parkinson</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://daparky.com/?p=382</guid>
		<description><![CDATA[When developing using PHP you&#8217;ll run into differen&#8217;t type of loops; while, for, foreach. Some web developers have a personal preference and try to use that loop for pretty much everything they do. Some loops work better for differen&#8217;t things while others don&#8217;t perform very well. One of my favourite loops is the foreach loop. [...]]]></description>
			<content:encoded><![CDATA[<p>When developing using PHP you&#8217;ll run into differen&#8217;t type of loops; while, for, foreach. Some web developers have a personal preference and try to use that loop for pretty much everything they do. Some loops work better for differen&#8217;t things while others don&#8217;t perform very well. One of my favourite loops is the foreach loop.</p>
<p>One thing I ran into was exiting the loop when after say 3 items have been listed.</p>
<p>This is what I did:</p>
<pre class="brush: php">

&lt;?php
$i=0;
foreach($files as $file) {
if ($i == 3) {
break;
} else {
$i++;
} ?&gt;

// do stuff here

&lt;?php
} ?&gt;
</pre>
<p>That&#8217;s it! Of course, some people prefer to do this with a for loop:</p>
<pre class="brush: php">

&lt;?php
for($i=0; $i&lt;3; $i++) { ?&gt;

// do stuff here

&lt;?php
} ?&gt;
</pre>
<p>At the end of the day it&#8217;s personal preference.</p>
<img src="http://daparky.com/?ak_action=api_record_view&id=382&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://daparky.com/exiting-a-foreach-loop-in-php/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Why I Use Codeigniter For My Web Applications</title>
		<link>http://daparky.com/why-i-use-codeigniter-for-my-web-applications/</link>
		<comments>http://daparky.com/why-i-use-codeigniter-for-my-web-applications/#comments</comments>
		<pubDate>Sun, 22 Nov 2009 17:33:49 +0000</pubDate>
		<dc:creator>David Parkinson</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[codeigniter]]></category>

		<guid isPermaLink="false">http://daparky.com/?p=359</guid>
		<description><![CDATA[A web developer at some point will look at how they can speed up their development and how to make it easier to develop web applications. If you want to make this possible you are going to have to look for a framework. The dynamic language i use is PHP because of it&#8217;s easy learning [...]]]></description>
			<content:encoded><![CDATA[<p>A web developer at some point will look at how they can speed up their development and how to make it easier to develop web applications. If you want to make this possible you are going to have to look for a framework. The dynamic language i use is PHP because of it&#8217;s easy learning curve. I&#8217;ve had a dabble with other languages such as ASP, i found PHP the easiest and it&#8217;s more widely used.</p>
<p>Around a year ago i started to look for a PHP framework, to see which one i&#8217;ll be using in the long term. I&#8217;ve tried many different frameworks and these include Zend, Cake and Symfony but the one that stood out the most was Codeigniter. Every framework comes with classes that will help you develop an application but it&#8217;s how easy it is to use them and this is where Codeigniter takes my pick.</p>
<p>Codeigniter is for you if:-</p>
<ul>
<li>You want a framework with a small footprint.</li>
<li>You need exceptional performance.</li>
<li>You need broad compatibility with standard hosting accounts that run a variety of PHP versions and configurations.</li>
<li>You want a framework that requires nearly zero configuration.</li>
<li>You want a framework that does not require you to use the command line.</li>
<li>You want a framework that does not require you to adhere to restrictive coding rules.</li>
<li>You are not interested in large-scale monolithic libraries like PEAR.</li>
<li>You do not want to be forced to learn a templating language (although a template parser is optionally available if you desire one).</li>
<li>You eschew complexity, favoring simple solutions.</li>
<li>You need clear, thorough documentation.</li>
</ul>
<p>Codeigniter delivers, it&#8217;s easy to setup, easy to use and has a great forum if you ever need any help.</p>
<p>Over the next few months i&#8217;ll be using this blog to track and show you any personal projects i work on. The kind of projects i want to produce are from small little applications such as image uploaders to full scale websites. Stay tuned!</p>
<img src="http://daparky.com/?ak_action=api_record_view&id=359&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://daparky.com/why-i-use-codeigniter-for-my-web-applications/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>An XSLT stylesheet does not have an XML mimetype</title>
		<link>http://daparky.com/an-xslt-stylesheet-does-not-have-an-xml-mimetype/</link>
		<comments>http://daparky.com/an-xslt-stylesheet-does-not-have-an-xml-mimetype/#comments</comments>
		<pubDate>Wed, 18 Nov 2009 08:29:33 +0000</pubDate>
		<dc:creator>David Parkinson</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[mimetype]]></category>
		<category><![CDATA[stylesheet]]></category>

		<guid isPermaLink="false">http://daparky.com/?p=344</guid>
		<description><![CDATA[If you take a look at your stylesheet whether it&#8217;s for a blog or a normal website (usually found at domain.com/sitemap.xml), does it throw up the following error: An XSLT stylesheet does not have an XML mimetype? If so what you need to do is put a .htaccess file in the root of your server [...]]]></description>
			<content:encoded><![CDATA[<p>If you take a look at your stylesheet whether it&#8217;s for a blog or a normal website (usually found at domain.com/sitemap.xml), does it throw up the following error: An XSLT stylesheet does not have an XML mimetype? If so what you need to do is put a .htaccess file in the root of your server (if you don&#8217;t already have one) and add the following to the bottom:</p>
<blockquote><p>AddType text/xsl .xsl</p></blockquote>
<p>What this basically does is make your server read those sort of files (.xsl) and therefore won&#8217;t throw any error up. After you&#8217;ve done that submit the sitemap to Google Webmaster Tools.</p>
<img src="http://daparky.com/?ak_action=api_record_view&id=344&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://daparky.com/an-xslt-stylesheet-does-not-have-an-xml-mimetype/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Moving/Importing Large MySQL Databases</title>
		<link>http://daparky.com/movingimporting-large-mysql-databases/</link>
		<comments>http://daparky.com/movingimporting-large-mysql-databases/#comments</comments>
		<pubDate>Mon, 16 Nov 2009 17:35:09 +0000</pubDate>
		<dc:creator>David Parkinson</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[bigdump]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://daparky.com/?p=341</guid>
		<description><![CDATA[In my daily job of web development i sometimes come to a grinding halt when a task i have to do requires a bit of tinkering. A week or two ago i had the task of moving a large mySQL Database from one server to another, and what a pain it was. First of all [...]]]></description>
			<content:encoded><![CDATA[<p>In my daily job of web development i sometimes come to a grinding halt when a task i have to do requires a bit of tinkering. A week or two ago i had the task of moving a large mySQL Database from one server to another, and what a pain it was.</p>
<p>First of all the size of this database was roughly 80MB, secondly the server only allowed a max upload of around 2MB via phpMyAdmin so i thought how the hell am i going to get this across. I did some research, looked on forums and basically searched Google for the answer and to be honest i didn&#8217;t find the answer until i ran into what looks like the best script to do the exact task.</p>
<p><a href="http://www.ozerov.de/bigdump.php" target="_blank">BigDump</a> did the job for me. I had the database moved across within the next hour, was happy and immediately bookmarked the site. If you are having trouble moving a database across due to hosting restrictions i highly recommend taking a look at <a href="http://www.ozerov.de/bigdump.php" target="_blank">BigDump</a>.</p>
<blockquote><p>To restore the very large backup of your mySQL database (or a part of it) into the new or the same mySQL database. You can&#8217;t access the server shell and you can&#8217;t import the dump using phpMyAdmin or any other scripts due to hard memory resp. runtime limit of the web server.</p></blockquote>
<p>It does exactly what it says on the tin. All you need to do is export the database from phpMyAdmin, upload the database to the same directory as bigdump.php, run the script and Kudos! You&#8217;ve imported a large database without any hassle.</p>
<p>If anyone has found any other scripts worth taking a look at, please let me know.</p>
<img src="http://daparky.com/?ak_action=api_record_view&id=341&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://daparky.com/movingimporting-large-mysql-databases/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

