Tour of Torfaen Half Marathon

By , Sunday 28th October 2007 10:00 am

What am I doing? I’ve been in bed all week with a bad cold, I’ve managed one run since the Cardiff Half where I pulled my left calf, and now I’m stood out in the freezing driving rain about to run another one!!! Standing at the start line, soaked to the bones already, the hooter goes…. here we go again :) Continue reading 'Tour of Torfaen Half Marathon'»

Stuck on 4096 characters???

By , Friday 26th October 2007 2:21 pm

I’ve come up with a problem recently returning data via an XML feed using AJAX. In my case I was returning a list of images each having several links to perform various tasks (e.g. set as main image, add as thumbnail, add full image, etc).

The first load would go through fine and all images and their links would appear as I’d expect. There was also no problems in IE7, Safari (on Windows), or Opera 9+. When it came to Firefox 2 the image list would be cut short! Editing the javascript it basically seems that the returned data would be cut off at 4096 characters.

It took a while to track down the result. I thought initially this might of been a javascript maximum string length problem, but that other browsers just let the issue slip. Not that either. Anyway it turns out that text nodes are split at 4096 characters.

It’s quite simple to fix you simply need to normalise() your returned data in your AJAX script. Simply add the second line once you’ve gathered your XML data:

xmlResponse = xmlHttp.responseXML;
xmlResponse.normalize();

This will solve the 4096 character limit when using Firefox 2 or any other browser I haven’t checked that doesn’t normalise the data automatically.

Quick and easy $_POST security…

By , Thursday 25th October 2007 7:44 pm

Please ignore this post, quite frankly its old and there’s much better ways to do stuff than this.

A quick and easy way to protect yourself from mySQL injection attacks in PHP is to use…

$sql = "insert into table set ";
 foreach ($_POST as $key => $data)
 {
     $sql .= $key." = '".strip_tags(htmlentities(addslashes($data)))."',";
 }
 $sql .= mysql_query(rtrim($sql,',').";") or die(mysql_error());

What this script does is to take your $_POST data and remove anything malicious from it. Looping over the $_POST data we build up an SQL statement. At the end then we simply execute using with mysql_query.

NOTE: This does not validate your data, it just helps prevent malicious attacks.

Another version of this that I use to to grab all my form information into variables to to place the following code within the foreach loop instead…

eval("$".$key." = '".strip_tags(htmlentities(addslashes($data)))."';");

This makes up a list of variables following your forms field names and strips malicious code from them. This method then allows you to do some form validation before inserting data into your tables ;)

Cardiff Half Marathon 2007

By , Sunday 14th October 2007 9:00 am

So today was it, my first half marathon. Training had gone fairly well, I’d managed to do my over the mountain half training several times my best time on that being 1 hour 57 mins roughly. A few days of tapering, which generally meant I felt rubbish and there I was standing on the start line at 8:30am. I finished in 1 hour 48 mins 44 seconds. Continue reading 'Cardiff Half Marathon 2007'»

Divesigns.com

By , Monday 1st October 2007 12:00 pm

DiVeSiGnS

Dive Signs required a low cost solution due to being a start up company. Dive Signs are a family run business based in Essex they sell highly reflective vinyl stickers for the scuba diving industry. The solution for Dive Signs was a customised install of Zen Cart, the entire site took less than one week to get up and running and they are already expanding their online catalogue.

Divesigns.com – Highly reflective vinyl signs for scuba diving

Panorama Theme by Themocracy

1 visitors online now
0 guests, 1 bots, 0 members
Max visitors today: 16 at 08:14 am UTC
This month: 17 at 19-09-2017 09:35 pm UTC
This year: 45 at 02-01-2017 10:28 pm UTC
All time: 130 at 28-03-2011 10:40 pm UTC