<?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>The Lab</title>
	<atom:link href="http://lab.pxwebdesign.com.au/feed" rel="self" type="application/rss+xml" />
	<link>http://lab.pxwebdesign.com.au</link>
	<description>The development blog for PX Webdesign</description>
	<pubDate>Tue, 09 Sep 2008 06:48:57 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5</generator>
	<language>en</language>
			<item>
		<title>IE6 wants to hide my post values - the horror!</title>
		<link>http://lab.pxwebdesign.com.au/programming/ie6-wants-to-hide-my-post-values/22</link>
		<comments>http://lab.pxwebdesign.com.au/programming/ie6-wants-to-hide-my-post-values/22#comments</comments>
		<pubDate>Tue, 09 Sep 2008 06:44:57 +0000</pubDate>
		<dc:creator>Lone</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<category><![CDATA[html form ie6 first value post missing bug]]></category>

		<guid isPermaLink="false">http://lab.pxwebdesign.com.au/?p=22</guid>
		<description><![CDATA[I hit what would have to be one of the freakiest and hardest to replicate bugs in IE6 today. It all started when a client said a form they were using was coming up with missing post index errors. I spent forever trying to replicate and see what they were doing. Simply put if they [...]]]></description>
			<content:encoded><![CDATA[<p>I hit what would have to be one of the freakiest and hardest to replicate bugs in IE6 today. It all started when a client said a form they were using was coming up with missing post index errors. I spent forever trying to replicate and see what they were doing. Simply put if they pasted a certain bit of content into a plain textarea box the first post value would automagically disappear. That first value for us was a hidden value defining if you were adding or editing an item - kind of important!</p>
<p><span id="more-22"></span>After plenty of searching I managed to come across the certain factors that need to be in place for this to happen and hopefully this might just one day help someone else out.</p>
<ul>
<li>Client using IE6</li>
<li>Form needs <em>enctype=&#8221;multipart/form-data&#8221;</em></li>
<li>Textarea value needs character that MS Word creates that is three dots</li>
</ul>
<p>Then upon submitting your first post value will dissappear. Here is a link to a <a href="http://bugs.php.net/bug.php?id=22427">PHP Bug thread</a> covering the issue - and it&#8217;s not PHP specific, its purely IE6. Below is the sample code that will reproduce the error:</p>
<p><code>
<pre>&lt;form method=&quot;post&quot; action=&quot;whatever&quot; enctype=&quot;multipart/form-data&quot;&gt;
&lt;input type=&quot;text&quot; name=&quot;field1&quot; value=&quot;1&quot;&gt;
&lt;input type=&quot;text&quot; name=&quot;field2&quot; value=&quot;2…&quot;&gt;
&lt;input type=&quot;checkbox&quot; name=&quot;field3&quot; value=&quot;3&quot;&gt;
&lt;input type=&quot;submit&quot;&gt;
&lt;/form&gt;
</pre>
<p></code></p>
<p>All I have done to stop it in the meantime is added a &#8216;fake&#8217; hidden post value at the start so it gets destroyed instead of a value that is actually required.</p>
]]></content:encoded>
			<wfw:commentRss>http://lab.pxwebdesign.com.au/programming/ie6-wants-to-hide-my-post-values/22/feed</wfw:commentRss>
		</item>
		<item>
		<title>Release details about Worganiser - finally!</title>
		<link>http://lab.pxwebdesign.com.au/projects/release-details-about-worganiser-finally/21</link>
		<comments>http://lab.pxwebdesign.com.au/projects/release-details-about-worganiser-finally/21#comments</comments>
		<pubDate>Mon, 08 Sep 2008 00:21:44 +0000</pubDate>
		<dc:creator>Lone</dc:creator>
		
		<category><![CDATA[Projects]]></category>

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

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

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

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

		<guid isPermaLink="false">http://lab.pxwebdesign.com.au/?p=21</guid>
		<description><![CDATA[Worganiser is an internal task and project management tool that we have developed here at PX Webdesign. We use it to help us keep track of what clients work is still to be done and assign tasks to each other. We have always invisaged on releasing this organiser to the public but not until it [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.worganiser.com">Worganiser</a> is an internal task and project management tool that we have developed here at <a href="http://www.pxwebdesign.com.au">PX Webdesign</a>. We use it to help us keep track of what clients work is still to be done and assign tasks to each other. We have always invisaged on releasing this organiser to the public but not until it had been fully tested in house.<span id="more-21"></span></p>
<p>We have started re-writing it now on the CodeIgniter framework along with giving it the extra dimension of multiple user accounts so you can signup to register a new account as this will be a hosted web application service. Some of the features include the following:</p>
<ul>
<li>Client contact management (phone numbers, email addresses etc.)</li>
<li>Project management</li>
<li>Project job management</li>
<li>Task/todo list management</li>
</ul>
<p>Whilst we don&#8217;t have an exact release date, we would hope with in the next 3 months will be the likely release date. If you do want to know more, be certain to <a href="http://www.worganiser.com">visit the site</a> and send us your email address to be updated when more information is available.</p>
]]></content:encoded>
			<wfw:commentRss>http://lab.pxwebdesign.com.au/projects/release-details-about-worganiser-finally/21/feed</wfw:commentRss>
		</item>
		<item>
		<title>A simple way to ease spam from forms</title>
		<link>http://lab.pxwebdesign.com.au/jquery/a-simple-way-to-ease-spam-from-forms/20</link>
		<comments>http://lab.pxwebdesign.com.au/jquery/a-simple-way-to-ease-spam-from-forms/20#comments</comments>
		<pubDate>Wed, 06 Aug 2008 06:00:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Programming]]></category>

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

		<category><![CDATA[jvascript jquery forms]]></category>

		<guid isPermaLink="false">http://lab.pxwebdesign.com.au/?p=20</guid>
		<description><![CDATA[A common request we get from many of our clients is &#8220;How do I stop spam coming through from forms on my website?&#8221;. Some client&#8217;s sites we have seen can get upto 80-100 spam emails in one day from forms on their website - this of course is very frustrating for them especially when you [...]]]></description>
			<content:encoded><![CDATA[<p>A common request we get from many of our clients is &#8220;How do I stop spam coming through from forms on my website?&#8221;. Some client&#8217;s sites we have seen can get upto 80-100 spam emails in one day from forms on their website - this of course is very frustrating for them especially when you need to look a bit closer at these emails in case they are a genuine email.</p>
<p>One of the common approaches these days is to use a image verification system (usually called <a href="http://psyrens.com/captcha/" target="_blank">Captcha</a>) but this can become very  annoying for an end user especially when it is difficult to read. Plus, these forms are usually enquiry/contact forms which are very critical to help generate sales for the client so making them unattractive and difficult to a end user can reduce the number of enquiries sent.<span id="more-20"></span></p>
<h2>Our Solution</h2>
<p>One of the common traits of the scripts out there that are auto spamming all of these forms is that they are done through very simple methods and don&#8217;t support features that most broswers do such as Javascript - we can use this to our advantage.</p>
<p>In your form create a hidden input and make its value empty such as the sample code below:</p>
<pre><code>&lt;input type=&quot;hidden&quot; name=&quot;js_check&quot; id=&quot;js_check&quot; value=&quot;&quot; /&gt;</code></pre>
<p>Now create a javascript file that is loaded on the form page and insert the following code:</p>
<h4>Raw Javascript</h4>
<pre><code>document.getElementById('js_check').value = 'pass';</code></pre>
<h4>or <strong>jQuery</strong> (in document.ready)</h4>
<pre><code>$('input[@name=js_check]').val('pass');</code></pre>
<p>Then all you need to do is where the form is posted to is check that $_POST[&#8217;js_check&#8217;] is equal to &#8216;pass&#8217;. If it isn&#8217;t then send the user back to the form and inform them that they need javascript required to complete the form.</p>
<p>I would usually jump up and down here and say &#8220;oh that&#8217;s not right to depend on javascript&#8221; but honestly speaking <a href="http://www.w3schools.com/browsers/browsers_os.asp" target="_blank">the stats show</a> that now 95% of people have it enabled and as long as you redirect them back informing them that they need it enabled they will know why the form was not sent.</p>
<p>For the amount of spam this stops for the minimal implementation time and small amount of users that maybe affected I think it is well worth adding to your forms instead of a Image Verification method.</p>
]]></content:encoded>
			<wfw:commentRss>http://lab.pxwebdesign.com.au/jquery/a-simple-way-to-ease-spam-from-forms/20/feed</wfw:commentRss>
		</item>
		<item>
		<title>Firefox 3 mulitple ajax requests not updating</title>
		<link>http://lab.pxwebdesign.com.au/codeigniter/firefox-3-mulitple-ajax-requests-not-updating/19</link>
		<comments>http://lab.pxwebdesign.com.au/codeigniter/firefox-3-mulitple-ajax-requests-not-updating/19#comments</comments>
		<pubDate>Tue, 29 Jul 2008 02:26:51 +0000</pubDate>
		<dc:creator>Lone</dc:creator>
		
		<category><![CDATA[CodeIgniter]]></category>

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

		<category><![CDATA[firefox ff3 3 firebug ajax cache]]></category>

		<guid isPermaLink="false">http://lab.pxwebdesign.com.au/?p=19</guid>
		<description><![CDATA[This morning I managed to get caught up trying to work out a problem I was facing with some content that was being updated via ajax (using jQuery). Whenever I went to perform the same action/url twice it wouldn&#8217;t update - in my case a toggle switch for displaying an item. It seemed to be [...]]]></description>
			<content:encoded><![CDATA[<p>This morning I managed to get caught up trying to work out a problem I was facing with some content that was being updated via ajax (using jQuery). Whenever I went to perform the same action/url twice it wouldn&#8217;t update - in my case a toggle switch for displaying an item. It seemed to be a caching problem but (suprisingly) IE7 worked fine so it started to point towards something wrong with Firefox 3.<span id="more-19"></span></p>
<p>After a quick search around I found I wasn&#8217;t alone with encountering the problem with a <a href="http://forums.mozillazine.org/viewtopic.php?f=25&amp;t=673135&amp;st=0&amp;sk=t&amp;sd=a&amp;start=30" target="_blank">thread on Mozillazine</a> discussing the same issue which then lead me to <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=441751">a bug report</a> covering the same problem.</p>
<h2>The culprit - FireBug</h2>
<p>I started to see a few posts in the bug report indicating that when you disable firebug (a FireFox plugin that most web developers have turned on - especially when trying to work out problems like this!) that the issue is no longer there. I gave it a go and sure enough the problem was gone.</p>
<p>FireBug for FireFox 3 is still in beta version and the current version that the problem is happening with 1.2.0b7 was only released a couple of weeks ago.</p>
<h2>The solution - downgrade</h2>
<p>I went hunting for an earlier beta version and still had the problem in beta 6, but managed to find a beta version that didn&#8217;t have this problem - beta 4.</p>
<p>I got it from the following site but the file to look for if wanting another mirror is firebug-1.2.0b4-fx.xpi</p>
<p><a href="http://releases.mozilla.org/pub/mozilla.org/addons/1843/" target="_blank">http://releases.mozilla.org/pub/mozilla.org/addons/1843/</a></p>
<h2>**Update 1**</h2>
<p>I did a bit more investigation and came across a way to still use the latest beta version (as I certain there would be a few bug fixes) and not encounter this problem. What you need to do is <strong>disable</strong> the<strong> &#8216;Net&#8217; panel </strong>in firebug and the problem is gone!</p>
<h2>**Update 2**</h2>
<p>Got excited that there was a new beta release (13) on 18th August only to find this same problem persisting. You would think that something as major as this would have been fixed within 5 beta releases! Additionally <a href="http://code.google.com/p/fbug/issues/detail?id=1029" target="_blank">here is a link</a> to the issue being seen by many others as well still.</p>
<p>I also made a test page so the developers can see exactly what is going on which is located <a href="http://lab.pxwebdesign.com.au/tests/firebugajax/" target="_blank">here</a>. Just turn on the console and net panels in firebug and you will see it stop working.</p>
]]></content:encoded>
			<wfw:commentRss>http://lab.pxwebdesign.com.au/codeigniter/firefox-3-mulitple-ajax-requests-not-updating/19/feed</wfw:commentRss>
		</item>
		<item>
		<title>Validate multiple forms with same class with jQuery Validator</title>
		<link>http://lab.pxwebdesign.com.au/jquery/validate-multiple-forms-with-same-class-with-jquery-validator/18</link>
		<comments>http://lab.pxwebdesign.com.au/jquery/validate-multiple-forms-with-same-class-with-jquery-validator/18#comments</comments>
		<pubDate>Tue, 08 Jul 2008 02:43:26 +0000</pubDate>
		<dc:creator>Lone</dc:creator>
		
		<category><![CDATA[Programming]]></category>

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

		<category><![CDATA[jquery form validate multiple]]></category>

		<guid isPermaLink="false">http://lab.pxwebdesign.com.au/?p=18</guid>
		<description><![CDATA[Ran into a very frustrating problem today whilst developing a dynamic form generator for Breeze CMS - we needed the jQuery Validator plugin (worth the download!) to be able to validate multiple forms (that had the same content) but the fun part was that we don&#8217;t know how many forms there would be. I thought [...]]]></description>
			<content:encoded><![CDATA[<p>Ran into a very frustrating problem today whilst developing a dynamic form generator for Breeze CMS - we needed the jQuery <a href="http://bassistance.de/jquery-plugins/jquery-plugin-validation/" target="_blank">Validator plugin</a> (worth the download!) to be able to validate multiple forms (that had the same content) but the fun part was that we don&#8217;t know how many forms there would be. I thought it would be as simple as setting a common class for the forms and attaching the validate function to them but it wasn&#8217;t.<span id="more-18"></span></p>
<p>Below is a sample of the code I originally tried</p>
<pre><code>$('.addFieldForm').validate({
event: "keyup",
rules: {
field_name: "required"
},
etc. etc.</code></pre>
<p>It would only end up submiting the first form using the above code. The solution thankfully wasn&#8217;t too complex - just took a while to think of the solution! What you need to do is use the &#8216;<a href="http://docs.jquery.com/Plugins/Validation/Validator/setDefaults#defaults" target="_blank">jQuery.validator.setDefaults</a>&#8216; option and set the validation details you are going to use for the forms. Then the big secret on how to attach to each form is below:</p>
<pre><code>$('.addFieldForm').each( function(){
$(this).validate();
});
</code></pre>
<p>Nice and simple solution!</p>
]]></content:encoded>
			<wfw:commentRss>http://lab.pxwebdesign.com.au/jquery/validate-multiple-forms-with-same-class-with-jquery-validator/18/feed</wfw:commentRss>
		</item>
		<item>
		<title>Gzip and cache CSS and Javascript files dynamically for faster page loads</title>
		<link>http://lab.pxwebdesign.com.au/codeigniter/gzip-and-cache-css-and-javascript-files-dynamically-for-faster-page-loads/17</link>
		<comments>http://lab.pxwebdesign.com.au/codeigniter/gzip-and-cache-css-and-javascript-files-dynamically-for-faster-page-loads/17#comments</comments>
		<pubDate>Wed, 25 Jun 2008 15:04:13 +0000</pubDate>
		<dc:creator>Lone</dc:creator>
		
		<category><![CDATA[CodeIgniter]]></category>

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

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

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

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

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

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

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

		<guid isPermaLink="false">http://lab.pxwebdesign.com.au/?p=17</guid>
		<description><![CDATA[David came across a handy script the other day that we have decided to implement into our CMS that dynamically Gzips and caches CSS and JS files - all without the need to have to change any of your HTML source destinations for those files. As a part of the implementation I also setup the [...]]]></description>
			<content:encoded><![CDATA[<p>David came across a <a href="http://farhadi.ir/works/smartoptimizer" target="_blank">handy script</a> the other day that we have decided to implement into our CMS that dynamically Gzips and caches CSS and JS files - all without the need to have to change any of your HTML source destinations for those files. As a part of the implementation I also setup the script to work within the standard CodeIgniter cache setup and file structure.<span id="more-17"></span></p>
<p>Below is how I have it setup at the moment in CodeIgniter and yes its not a controller as such but pretty much acts like one and keeps all application code in the one spot hence the location/setup.</p>
<p>(If you are like me and have application folder set outside of the system folder then remove all instances of ‘system/’ and set the baseDir with one less ‘../’)</p>
<p>1. <strong>Extract</strong> the ‘smartoptimizer’ folder into <em>‘system/application/controllers/smartoptimizer’</em></p>
<p>2. Add the smartoptimizer <strong>htaccess details</strong> to the bottom of my htaccess details and replace all instances of <em>‘smartoptimizer/’</em> with <em>‘system/application/controllers/smartoptimizer/’</em></p>
<p>3. <strong>Edit</strong> <em>‘system/application/controllers/smartoptimizer/config.php’</em> and change the following settings as below:</p>
<pre><code class="php">$settings['baseDir'] = '../../../';
$settings['cacheDir'] to '../../cache/';</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://lab.pxwebdesign.com.au/codeigniter/gzip-and-cache-css-and-javascript-files-dynamically-for-faster-page-loads/17/feed</wfw:commentRss>
		</item>
		<item>
		<title>List duplicate database queries in CodeIgniter</title>
		<link>http://lab.pxwebdesign.com.au/codeigniter-libraries/list-duplicate-database-queries-in-codeigniter/16</link>
		<comments>http://lab.pxwebdesign.com.au/codeigniter-libraries/list-duplicate-database-queries-in-codeigniter/16#comments</comments>
		<pubDate>Tue, 24 Jun 2008 04:53:49 +0000</pubDate>
		<dc:creator>Lone</dc:creator>
		
		<category><![CDATA[CodeIgniter]]></category>

		<category><![CDATA[CodeIgniter Libraries]]></category>

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

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

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

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

		<guid isPermaLink="false">http://lab.pxwebdesign.com.au/?p=16</guid>
		<description><![CDATA[Sure we all like to think that we&#8217;re masters of our code but there does come times that you may not realise a database query (usually from a model) has been duplicated a few times. Sure it&#8217;s no big problem but when it comes to optimising your website this is one of the first things [...]]]></description>
			<content:encoded><![CDATA[<p>Sure we all like to think that we&#8217;re masters of our code but there does come times that you may not realise a database query (usually from a model) has been duplicated a few times. Sure it&#8217;s no big problem but when it comes to optimising your website this is one of the first things I would start hunting down to increase performance of a site - you&#8217;ve already got the dataset once so why do you need it again if it hasn&#8217;t been changed?<span id="more-16"></span></p>
<h2>Enabling the CodeIgniter Profiler</h2>
<p>Showing the duplicate queries in CI is easily achieved with the addition of a Library Extension that extends the <a href="http://codeigniter.com/user_guide/general/profiling.html" target="_blank">standard profiler</a>. If you haven&#8217;t already started using this handy debug tool you should switch it on as it&#8217;s easy to do - just at the bottom of any controller function/method just insert the following:</p>
<pre><code class="php">$this-&gt;output-&gt;enable_profiler(TRUE);</code></pre>
<h2>Listing the duplicate database queries</h2>
<p><img class="image_r_b" src="http://lab.pxwebdesign.com.au/uploads/images/my_profiler.jpg" alt="sample profiler" width="200" height="159" />It is as simple as opening the following file and saving it as &#8216;MY_Profiler.php&#8217; in your &#8216;application/libraries&#8217;  folder. Once placed in there any duplicate queries will be shown along with the number of duplications of each query.</p>
<p><a href="http://lab.pxwebdesign.com.au/ci/libraries/MY_Profiler.phps">Click to view the file</a></p>
<p><strong>Notes</strong><br />
- If you are having any problems trying to get it work please feel free to comment in here<br />
- If you have found any errors please let us know<br />
- Yes, I chose the sexy Magento colour</p>
]]></content:encoded>
			<wfw:commentRss>http://lab.pxwebdesign.com.au/codeigniter-libraries/list-duplicate-database-queries-in-codeigniter/16/feed</wfw:commentRss>
		</item>
		<item>
		<title>Darken or lighten colours dynamically using PHP</title>
		<link>http://lab.pxwebdesign.com.au/programming/darken-or-lighten-colours-dynamically-using-php/14</link>
		<comments>http://lab.pxwebdesign.com.au/programming/darken-or-lighten-colours-dynamically-using-php/14#comments</comments>
		<pubDate>Tue, 17 Jun 2008 12:59:41 +0000</pubDate>
		<dc:creator>Lone</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<category><![CDATA[php darken lighten hex colour color]]></category>

		<guid isPermaLink="false">http://lab.pxwebdesign.com.au/?p=14</guid>
		<description><![CDATA[For a recent client&#8217;s site we needed to have a function that would be able to darken a given hex colour (eg. #f4129c) on the fly (it was changing the border colour to be darker then the background colour). It took a while to find anything that could remotely do this as many samples seemed [...]]]></description>
			<content:encoded><![CDATA[<p>For a recent client&#8217;s site we needed to have a function that would be able to darken a given hex colour (eg. #f4129c) on the fly (it was changing the border colour to be darker then the background colour). It took a while to find anything that could remotely do this as many samples seemed to have flaws with certain colours. We also decided to make our own function able to make a colour lighter as well as darker.<span id="more-14"></span></p>
<p>Below is the function that we developed for this - we got a few ideas for the function from the <a href="http://www.barelyfitz.com/projects/csscolor/" target="_blank">CSS Colors Class</a> developed by <a href="http://www.barelyfitz.com/" target="_blank">BarelyFitz Designs</a> and we highly recommend this class if you are needing more  advanced colour functions such as colour comparing.</p>
<p>Below is a snippet of the code and usuage guide.</p>
<h2>PHP Function</h2>
<pre><code class="php">function colourBrightness($hex, $percent) {
	// Work out if hash given
	$hash = '';
	if (stristr($hex,'#')) {
		$hex = str_replace('#','',$hex);
		$hash = '#';
	}
	/// HEX TO RGB
	$rgb = array(hexdec(substr($hex,0,2)), hexdec(substr($hex,2,2)), hexdec(substr($hex,4,2)));
	//// CALCULATE
	for ($i=0; $i&#60;3; $i++) {
		// See if brighter or darker
		if ($percent &#62; 0) {
			// Lighter
			$rgb[$i] = round($rgb[$i] * $percent) + round(255 * (1-$percent));
		} else {
			// Darker
			$positivePercent = $percent - ($percent*2);
			$rgb[$i] = round($rgb[$i] * $positivePercent) + round(0 * (1-$positivePercent));
		}
		// In case rounding up causes us to go to 256
		if ($rgb[$i] &#62; 255) {
			$rgb[$i] = 255;
		}
	}
	//// RBG to Hex
	$hex = '';
	for($i=0; $i &#60; 3; $i++) {
		// Convert the decimal digit to hex
		$hexDigit = dechex($rgb[$i]);
		// Add a leading zero if necessary
		if(strlen($hexDigit) == 1) {
		$hexDigit = &#34;0&#34; . $hexDigit;
		}
		// Append to the hex string
		$hex .= $hexDigit;
	}
	return $hash.$hex;
}
</code></pre>
<h2>Function Usuage</h2>
<p>You do not have to give the colour with the &#8216;#&#8217; in fron but if you do it will still return the new hex colour with the &#8216;#&#8217; auto-magically.</p>
<h2><small>Lighten a colour</small></h2>
<pre><code class="php">$colour = '#ae64fe';
$brightness = 0.5; // 50% brighter
$newColour = colourBrightness($colour,$brightness);</code></pre>
<h2><small>Darken a colour</small></h2>
<pre><code class="php">$colour = '#ae64fe';
$brightness = -0.5; // 50% darker
$newColour = colourBrightness($colour,$brightness);</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://lab.pxwebdesign.com.au/programming/darken-or-lighten-colours-dynamically-using-php/14/feed</wfw:commentRss>
		</item>
		<item>
		<title>Get HREF attribute keeps on returning absolute link not relative link</title>
		<link>http://lab.pxwebdesign.com.au/jquery/get-href-attribute-keeps-on-returning-absolute-link-not-relative/13</link>
		<comments>http://lab.pxwebdesign.com.au/jquery/get-href-attribute-keeps-on-returning-absolute-link-not-relative/13#comments</comments>
		<pubDate>Fri, 13 Jun 2008 02:32:44 +0000</pubDate>
		<dc:creator>Lone</dc:creator>
		
		<category><![CDATA[Programming]]></category>

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

		<category><![CDATA[javascript jquery ajax href attribute]]></category>

		<guid isPermaLink="false">http://lab.pxwebdesign.com.au/?p=13</guid>
		<description><![CDATA[Whilst working on our new Image Manager in Breeze we came across an interesting bug that was causing images to be incorrectly linked to in the editor due to Internet Explorer (IE6 &#38; IE7 intermittently) returning the wrong HREF value for a link.
The link we were getting the HREF value from was set as below
&#60;a [...]]]></description>
			<content:encoded><![CDATA[<p>Whilst working on our new Image Manager in Breeze we came across an interesting bug that was causing images to be incorrectly linked to in the editor due to Internet Explorer (IE6 &amp; IE7 intermittently) returning the wrong HREF value for a link.<span id="more-13"></span></p>
<p>The link we were getting the HREF value from was set as below</p>
<pre><code class="php">&lt;a href=&quot;uploads/images/photo.jpg&quot;&gt;&lt;/a&gt;</code></pre>
<p>We were trying to obtain the HREF using jQuery with the following code:</p>
<pre><code class="php">$(this).attr('href')</code></pre>
<p>But this would return the absolute link (eg. http://www.domain.com/uploads/images/photo.jpg) instead of the HREF that was set. Usually we would use absolute links everywhere but didn&#8217;t in this case as we just needed the image address.</p>
<p>We then tried the basic javascript way of getting the href as below which still didn&#8217;t work:</p>
<pre><code class="php">&lt;a href=&quot;uploads/images/photo.jpg&quot; onclick=&quot;alert(this.href);return false;&quot;&gt;&lt;/a&gt;</code></pre>
<p>We then found the <a href="http://www.glennjones.net/Post/809/getAttributehrefbug.htm">following post</a> which worked but as our system was using AJAX later to get more links for some reason IE still wanted to automatically append the full URL.</p>
<pre><code class="php">&lt;a href=&quot;uploads/images/photo.jpg&quot; onclick=&quot;alert(this.getAttribute('href',2));return false;&quot;&gt;</code></pre>
<p>In the end we went for the way that was our last option. We output the absolute link and we set a hidden input field with our base_url (eg. http://www.domain.com/) and then did a replace over the href with the base_url. Not the most elegant solution but unfortunately the only way we could get it to work:</p>
<pre><code class="php">var href = $(this).attr('href');
var imgPathFull = href.replace($('input[@name=base_url]').val(),'');
var img = '<img src="' + imgPathThumb + '" alt="" />&#8216;;
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://lab.pxwebdesign.com.au/jquery/get-href-attribute-keeps-on-returning-absolute-link-not-relative/13/feed</wfw:commentRss>
		</item>
		<item>
		<title>Stopping mySQL &#8220;too many connections&#8221; errors in PHP</title>
		<link>http://lab.pxwebdesign.com.au/general/stopping-mysql-too-many-connections-errors-in-php/11</link>
		<comments>http://lab.pxwebdesign.com.au/general/stopping-mysql-too-many-connections-errors-in-php/11#comments</comments>
		<pubDate>Sun, 18 May 2008 11:49:49 +0000</pubDate>
		<dc:creator>Lone</dc:creator>
		
		<category><![CDATA[General]]></category>

		<category><![CDATA[php codeigniter pconnect mysql connections]]></category>

		<guid isPermaLink="false">http://lab.pxwebdesign.com.au/?p=11</guid>
		<description><![CDATA[At 5:03pm last Friday afternoon whilst demoing a new site to a client I came to see the ever so lovely &#8220;too many connections&#8221; error from mySQL (or in the case of CodeIgniter - could not connect to database error). I knew what was going to hit me next, the calls from clients who are [...]]]></description>
			<content:encoded><![CDATA[<p>At 5:03pm last Friday afternoon whilst demoing a new site to a client I came to see the ever so lovely &#8220;too many connections&#8221; error from mySQL (or in the case of CodeIgniter - could not connect to database error). I knew what was going to hit me next, the calls from clients who are having problems as well accessing their websites - and sure enough about 5 minutes later they started to come through so I just did a quick restart of mySQL and Apache which cleared the problem, but I wanted to work out how to stop this from happening again.</p>
<p><span id="more-11"></span>The first thing I did was to look at the current connections in the mySQL server so I could see what sites were causing the problems which can be achieved by the following when accessing your server by SSH:</p>
<pre><code class="php">mysqladmin -uUSERNAME -pPASSWORD processlist</code></pre>
<p>The first thing that came to my attention was a heap of connections left in sleep mode for 10000 seconds and over! Obviously these were counting to the &#8216;max_connections&#8217; standard setting of 100.</p>
<p>The other thing I found odd was that majority of these databases were all CodeIgniter (a PHP framework) based. After a bit of quick research I was able to narrow the problem down to the use of the mySQL pconnect (persistant connection) option with <a href="http://dev.mysql.com/doc/refman/5.0/en/too-many-connections.html">many suggestions</a> on not needing to use it. The odd thing was that CodeIgniter has this set to be ON by default and hence why all of these sites were appearing in the processlist.</p>
<p>To fix this issue in CodeIgniter simply goto your /application/config/database.php file and change the following setting as follows:</p>
<pre><code class="php">$db['default']['pconnect'] = FALSE; // Was set to TRUE</code></pre>
<p>For anyone else using PHP avoid using the &#8216;mysql_pconnect&#8217; command and use the &#8216;mysql_connect&#8217; command instead.</p>
<p>And lastly for anyone using a server and needing to stop other sites from using this you can change the following setting in your php.ini file:</p>
<pre><code class="php">[MySQL]
; Allow or prevent persistent links.
mysql.allow_persistent = Off</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://lab.pxwebdesign.com.au/general/stopping-mysql-too-many-connections-errors-in-php/11/feed</wfw:commentRss>
		</item>
	</channel>
</rss>
