<?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>Web Development Learnings &#187; PHP</title>
	<atom:link href="http://stevethomas.com.au/cat/php/feed" rel="self" type="application/rss+xml" />
	<link>http://stevethomas.com.au</link>
	<description>according to Steve Thomas</description>
	<lastBuildDate>Wed, 04 Jan 2012 08:07:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>How to Run Cron Jobs in CodeIgniter</title>
		<link>http://stevethomas.com.au/php/how-to-run-cron-jobs-in-codeigniter.html</link>
		<comments>http://stevethomas.com.au/php/how-to-run-cron-jobs-in-codeigniter.html#comments</comments>
		<pubDate>Wed, 04 Jan 2012 07:33:07 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://stevethomas.com.au/?p=258</guid>
		<description><![CDATA[<p>After a fair bit of <a href="http://www.google.com.au/#hl=en&#38;cp=17&#38;gs_id=1v&#38;xhr=t&#38;q=codeigniter+cron+job&#38;fp=b37e0351d48c1ee9" target="_blank">trawling</a> Google, I got the impression that setting up a cron job in codeigniter was going to be a bit tricky.</p>
<p>The two potential solutions I discovered were:</p>
<ol>
<li>execute the &#8220;wget&#8221; command to replicate a normal browser request, which then exposes my cron functionality to the big wide world and creates some additional unnecessary overheads, or</li>
<li>Create a bespoke front controller a bit like the existing index.php but specifically for cron jobs</li>
</ol>
<p>Neither of these options sound particularly ideal to me, and <strong>thankfully, there is a better way</strong> (and it turned out to be a case of <a href="http://codeigniter.com/user_guide/general/cli.html" target="_blank">RTFM</a>).</p>
<p>Firstly, just create a normal controller. I creatively called mine Cron.</p>
<p>Note the call to $this-&#62;input-&#62;is_cli_request() which ensures that <strong>this controller cannot be accessed directly from a url</strong>.</p>
<p>Next we setup our cron job as you would any other, except that you provide the path in a special format.</p>
<blockquote><p>php /path/to/index.php controller_name method_name ["params"]</p></blockquote>
<p>The first part is either the command &#8220;php&#8221; or your server path to php.</p>
<p>The second part is the absolute path to your CI front controller, eg. /path/to/index.php.</p>
<p>The third part is the controller name, followed by the method name, followed by optional parameters.</p>
<p>The CI manual gives the example:</p>
<blockquote><p>php /path/to/index.php cron foo</p></blockquote>
<p>If that doesn&#8217;t work you might need to specify your path to php. I set mine as follows:</p>
<blockquote><p>/usr/local/bin/php -f /home/clinic/public_html/index.php cron foo</p></blockquote>
<p>You can even pass parameters in quotes, which have the same effect as parameters in regular url requests!</p>
<blockquote><p>/usr/local/bin/php -f /home/clinic/public_html/index.php cron foo &#8220;beer&#8221;</p></blockquote>
<p><img title="impressive" src="http://stevethomas.com.au/wp-content/uploads/2012/01/images.jpg" alt="" width="225" height="225" /></p>
]]></description>
		<wfw:commentRss>http://stevethomas.com.au/php/how-to-run-cron-jobs-in-codeigniter.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CodeIgniter Getting Started Surprises</title>
		<link>http://stevethomas.com.au/php/codeigniter-getting-started-surprises.html</link>
		<comments>http://stevethomas.com.au/php/codeigniter-getting-started-surprises.html#comments</comments>
		<pubDate>Mon, 25 Apr 2011 03:02:54 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://stevethomas.com.au/?p=185</guid>
		<description><![CDATA[<p>I&#8217;ve been looking into the CodeIgniter PHP framework (CI)  for a couple of weeks and want to document some of the surprises and caveats I have discovered. Coming from a non-framework background, I was surprised at how similar the CI conventions are to my own pseudo &#8220;framework&#8221; that I use on my projects &#8211; so I guess I must&#8217;ve been doing something right so far!</p>
<p>This is what i&#8217;ve learnt.</p>
<h3>CI is backwards compatible with PHP4</h3>
<p><strong></strong>Which, in my opinion is something they should rectify &#8211; ie. retire support in the next major release and move forward. From what I have read about CI vs Kohana (a CI fork), it seems that CI is sacrificing pretty autoloading simply because they remain backwards compatible.</p>
<p><em><span style="color: #ff0000;">Edit:</span> This is actually incorrect, as of version 2.0.2 the minimum required version of PHP is 5.1.6. Thats to Dale for pointing this out in the comments.</em></p>
<h3>The MVC structure is superb, however&#8230;</h3>
<p><strong></strong>Alot of tutorials i&#8217;ve watched lean towards using helper functions within views, such as for forms. From a developer perspective thats fine, however you can imagine a designer having problems with form_open() when he wants to add a simple class or ID. The upside is that they are just helpers &#8211; if you don&#8217;t like them, don&#8217;t use them.</p>
<h3>Speaking of functions</h3>
<p><strong></strong>I was surprised to discover the folder full of procedural helper functions. This is nice in terms of using functions anywhere inside the application, although it does seem a little out of place in an OOP framework. It would be nice to see these converted into classes.</p>
<h3>Default session security is awful</h3>
<p><strong></strong>Usually a PHP session&#8217;s data is stored server side and only a small cookie is kept client side to track a user session. However in CI, the session data is stored <em>client</em>&#8230; <a href="http://stevethomas.com.au/php/codeigniter-getting-started-surprises.html" class="read_more">Read more</a></p>]]></description>
		<wfw:commentRss>http://stevethomas.com.au/php/codeigniter-getting-started-surprises.html/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>How to duplicate a phpBB3 theme</title>
		<link>http://stevethomas.com.au/php/how-to-duplicate-a-phpbb3-theme.html</link>
		<comments>http://stevethomas.com.au/php/how-to-duplicate-a-phpbb3-theme.html#comments</comments>
		<pubDate>Wed, 02 Jul 2008 01:51:16 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://stevethomas.com.au/?p=51</guid>
		<description><![CDATA[<p>If you ever want to duplicate an existing phpBB3 theme, you might be sorely frustrated when you can&#8217;t seem to get any of your changes to take hold. It is sometimes necessary to go to the ACP, and hit purge the cache, however there is a further trick.</p>
<p>First, duplicate the theme folder you want to start with, and rename to your theme name.</p>
<p>Second, you need to go to the theme folder, and open style.cfg, /imageset/imageset.cfg, /template/template.cfg, /theme/theme.cfg, in a text editor. All of these files contain name = value. Rename all of these to your theme name.</p>
<p>Upload all of these changes, then head to the ACP and go to the &#8220;styles&#8221; tab. Click install on your theme.  On the left hand menu, go to each of the style components, and select install for each one. Then head back to the main styles page and click &#8220;details&#8221; for your theme. Select the imageset, template and theme from the dropdown menu.</p>
<p>Now you should be done!</p>
]]></description>
		<wfw:commentRss>http://stevethomas.com.au/php/how-to-duplicate-a-phpbb3-theme.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to make a tag cloud in PHP, MySQL and CSS</title>
		<link>http://stevethomas.com.au/php/how-to-make-a-tag-cloud-in-php-mysql-and-css.html</link>
		<comments>http://stevethomas.com.au/php/how-to-make-a-tag-cloud-in-php-mysql-and-css.html#comments</comments>
		<pubDate>Wed, 22 Aug 2007 01:42:20 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://stevethomas.com.au/php/how-to-make-a-tag-cloud-in-php-mysql-and-css.html</guid>
		<description><![CDATA[<p><strong>Update May 2011: Almost 4 years on, this post continues to get heaps of traffic and comments so i&#8217;m going to attempt to answer some of the most FAQ. I have added the MySQL table structure and demonstrated how a basic search page would work to increment the search term counter. I&#8217;ve also added some pretty CSS3 and added a last search date for each term. If you just want the files to download, skip to the end. </strong></p>
<p>Today I wanted to make a tag cloud, but all my searching proved fruitless &#8211; so I decided to stop being lazy and just work it out myself!</p>
<p>First you&#8217;ll need a database that stores the keywords and search terms.</p>
<p>Each time a user performs a search, we will check to see if the term has been searched before. If it has, we will increment the counter for that term. If the term has not been searched for before, we will insert the search term with a counter value of 1.</p>
<p>Lets begin with a basic MySQL table structure for the search table:</p>
<p>Now lets make a search page. Here is some basic HTML to get started with:</p>
<p>In the next section, we are going to accomplish three things:</p>
<ol>
<li>Connect to the database</li>
<li>Handle new searches so that the counter can be updated</li>
<li>query the database searches to build a PHP array of search terms</li>
</ol>
<p>Next we&#8217;ll setup a bit of css. Feel free to adjust these as you see fit.</p>
<p>Finally we just want to loop through the array and display it with the appropriate css class.</p>
<p>And thats it! Hope this saves someone some time. Add your comments below!</p>
<p>I have combined this tutorial into a single file,  <strong><a href="http://stevethomas.com.au/wp-content/uploads/2011/10/tagcloud.zip">download the full example here</a></strong>.</p>
]]></description>
		<wfw:commentRss>http://stevethomas.com.au/php/how-to-make-a-tag-cloud-in-php-mysql-and-css.html/feed</wfw:commentRss>
		<slash:comments>96</slash:comments>
		</item>
		<item>
		<title>What is a Cron Job?</title>
		<link>http://stevethomas.com.au/php/what-is-a-cron-job.html</link>
		<comments>http://stevethomas.com.au/php/what-is-a-cron-job.html#comments</comments>
		<pubDate>Wed, 15 Aug 2007 12:31:27 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://stevethomas.com.au/php/what-is-a-cron-job.html</guid>
		<description><![CDATA[<p><strong>Q: What is a cron job?</strong></p>
<p><strong>A:</strong>  A cron job is an automated task that runs on a linux server, similar to Scheduled Tasks on windows.</p>
<p>The main idea is that you can run a process without you or someone else manually setting it off &#8211; my first experience with cron jobs was when working with an online auction website. As you can imagine, an auction runs for a fixed time period. So lets say an auction runs for 7 days. What happens at the end of 7 days? The database says this auction is closed. If the auction did not sell, whether the reserve was not met, or their were no bids at all, then we want to automatically relist that auction.</p>
<p>There are two options:</p>
<p>a) run a process when a page load occurs&#8230; sucks because the page load is gunna take longer due to the extra processes occurring</p>
<p>b) run a cron job every x minutes, looking for auctions that have passed their end time, and either relist them or close them down permanently</p>
<p>I tend to code in PHP and MySQL, which means that I create a PHP file that does all the maintenance tasks  required and I run it at set intervals. The cool thing is, if you want to be running different tasks at multiple times of the day/week/year, just setup multiple cron jobs.</p>
<p><strong>Thats great, but how the hell do I setup a cron job? </strong></p>
<p>I&#8217;m glad you asked!</p>
<p>If you are comfortable working with command line, then you might want to visit <a href="http://www.aota.net/Script_Installation_Tips/cronhelp.php3">a site like this</a>. If, like me, you <strong>have access to cPanel, life is much, much easier.</strong></p>
<p><strong>How to setup a cronjob in cPanel </strong></p>
<p>1. login to cPanel</p>
<p>2. click on the cron jobs tab (near the&#8230; <a href="http://stevethomas.com.au/php/what-is-a-cron-job.html" class="read_more">Read more</a></p>]]></description>
		<wfw:commentRss>http://stevethomas.com.au/php/what-is-a-cron-job.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>MySQL Reserved Words</title>
		<link>http://stevethomas.com.au/php/mysql-reserved-words.html</link>
		<comments>http://stevethomas.com.au/php/mysql-reserved-words.html#comments</comments>
		<pubDate>Mon, 25 Jun 2007 12:48:44 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://stevethomas.com.au/uncategorized/mysql-reserved-words.html</guid>
		<description><![CDATA[<p>The database language MySQL has a  number of reserved words that should not be used in queries or for field names. Some of the big ones are:</p>
<ul>
<li> Add</li>
<li>All</li>
<li>Between</li>
<li>Both</li>
<li>Check</li>
<li>Current_Date</li>
<li>Drop</li>
<li>For</li>
<li>From</li>
<li>Group</li>
<li>INT</li>
<li>Key</li>
<li>Load</li>
<li>Lock</li>
<li>Null</li>
<li>On</li>
<li>Out</li>
<li>Real</li>
<li>Repeat</li>
<li>Table</li>
<li>Use</li>
<li>Write</li>
</ul>
<p>And so it goes. I came across the official list when I couldn&#8217;t work out why this query wouldn&#8217;t work:<br />
[SQL]SELECT COUNT(id) FROM messages WHERE read = ‘0′ AND to = $logged_in_id[/SQL]</p>
<p>The reason? Both &#8220;to&#8221; and &#8220;read&#8221; are reserved words and the query failed. See the full list here:</p>
<p><a href="http://dev.mysql.com/doc/refman/5.0/en/reserved-words.html" title="MySQL Reserved Words">http://dev.mysql.com/doc/refman/5.0/en/reserved-words.html </a></p>
]]></description>
		<wfw:commentRss>http://stevethomas.com.au/php/mysql-reserved-words.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PHP and why you should use it</title>
		<link>http://stevethomas.com.au/php/php-and-why-you-should-use-it.html</link>
		<comments>http://stevethomas.com.au/php/php-and-why-you-should-use-it.html#comments</comments>
		<pubDate>Fri, 02 Feb 2007 09:25:14 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://stevethomas.com.au/uncategorized/php-and-why-you-should-use-it.html</guid>
		<description><![CDATA[<p>PHP is a programming language that is arguably one of the easiest to learn, cost efficient and common languages out there. It is used primarily to create <strong>dynamic website content</strong>. By dynamic I mean that it flows and it can change in a way that <strong>static website content</strong> can not.</p>
<p>With so much time invested by individuals and businesses in establishing themselves with a programming language, bias is inevitable, and you don&#8217;t have to dig deep to find someone criticising PHP. But then, the same goes for any language. Each has their own advantages and disadvantages.</p>
<p>What remains a fact is that PHP has been popular in the past, is popular now, and will continue to be popular well into the future.</p>
<p><strong>Some of PHP&#8217;s advantages include: </strong></p>
<ul>
<li>Considered easy to learn as far as programming languages go, meaning it is very well known in the web development community</li>
<li> Hosting is more common and cheaper than for any other language</li>
<li>Large range of turnkey php applications available, some free, some not. Examples include WordPress, (the software this forum is running on), phpBB and wikipedia.</li>
<li>Abundance of free online resources</li>
</ul>
<p><strong>Here is a classic usage for PHP;</strong><br />
<em>Situation </em>- A shop owner wishes to supplement their traditional shop with an online shop, in the form of a 500 product website.<br />
<em>Solution A:</em> Build a static website, and make 500 separate pages to accommodate each and every product.<br />
<em>Solution B:</em> Build a dynamic website, create 1 product page and create 500 database entries</p>
<p>So what is the difference? In any case, the shop owner / web developer is going to have to process 500 products. Sure this sucks, at least initially.</p>
<p>PHP starts flexing its muscle when we get to the ongoing management side of things. The&#8230; <a href="http://stevethomas.com.au/php/php-and-why-you-should-use-it.html" class="read_more">Read more</a></p>]]></description>
		<wfw:commentRss>http://stevethomas.com.au/php/php-and-why-you-should-use-it.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Server Side Includes</title>
		<link>http://stevethomas.com.au/php/server-side-includes.html</link>
		<comments>http://stevethomas.com.au/php/server-side-includes.html#comments</comments>
		<pubDate>Sun, 10 Dec 2006 11:43:28 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://stevethomas.com.au/uncategorized/server-side-includes.html</guid>
		<description><![CDATA[<p>One of <a href="http://www.php.net" target="_blank">php</a>&#8216;s most practical solutions is a <strong>server side include</strong>.</p>
<p>Consider the navigation at the top of every page on this website. At time of writing there is 7 unique pages on thomasmultimedia.com.au, excluding this blog. If I were to add a new page to my site, would I not have to update each and every page to show the new link?</p>
<p>What a horrible sounding job &#8212; what if I had to make 2 or 3 changes to each and every one of those pages? In the context of 7 pages this might take say 10-15 minutes to open, change, save and upload 7 files. But what about if I have 20, 50, or 1000 different pages? <strong>This could take a day, if not a week!</strong></p>
<p>What a horrible way to spend a week&#8230; and yet i&#8217;m sure someone, somewhere, in a deep, dark dungeon has slaved away at this menial task for hours on end.</p>
<p><em>  All bow to King server side include!</em></p>
<p>A <strong>Server Side Include</strong> is a fairly ordinary file that is created for a website. It can contain any kind of web friendly content, but the most common usage is to display the same things over and over on different pages. So utilising this fantastic technology I have 1 file that contains my main navigation. If I want to rename, add, delete&#8230; or make any change under the sun, a server side include is my friend. I change the file once, and like magic every instance of the file is now reflecting the changes. Cool huh?</p>
<p>For any web people who have just read this post, don&#8217;t worry, I won&#8217;t leave you in the dark about <strong>how to do it</strong> &#8211; my favourite method is php.</p>
<p><strong>For Dreamweaver users</strong>, use brackets &#8211;&#8230; <a href="http://stevethomas.com.au/php/server-side-includes.html" class="read_more">Read more</a></p>]]></description>
		<wfw:commentRss>http://stevethomas.com.au/php/server-side-includes.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

