My Unecessary csv Conversion

I’m finding that I’m doing some things the hard way, maybe it’s just I’m looking at problems differently to others. Take my latest fun freelance challenge:

Convert data from csv and import into database using phpMyAdmin (access details will be supplied).

I saw this as: convert .csv file to sql file then use phpMyAdmin to process sql file either by quoting sql in the sql query screen or using the import from sql file.

The simplest way to see this is actually:
get data from .csv file into database using phpmyadmin as database access.

The difference might be subtle but my first solution was a quite a bit more complex. Continue reading My Unecessary csv Conversion

Navigation revisited and freeing your thinking

Revisiting Navigation

Last month I set out my view of using <nav> and <ul>s for navigation purposes. This was as a reaction to feelings in the php development community against changing the default behaviour of <ul>s using css.

The message that came across clearly after the fact was: the objection was not to the use of <ul>s as parent elements for a list of links. The problem comes with the styling:
/*css seen as a problem */
ul {text-align:center;list-style-type:none;}
a{display:block;padding:2px 5px;}

The problem is that default behaviour for all <ul>s is changed so <ul>s elsewhere in the page will be styled like this.

/*css seen as a reasonable solution */
nav ul{text-align:center;list-style-type:none;}
nav li {float:left;}
nav a{display:block;padding:2px 5px;}

Just the behaviour for children of the <nav> element is changed leaving other <ul>s to be styled differently (or defaultly).

This is a really subtle distinction and I don’t mind admitting it took me a while to sus out. The argument isn’t against using <ul>s in navigation but advises us to do so in a careful and considered way.

Not using <ul>s closes the door to such enhancements as submenus and accordian style menu layout. This shows up my intial example last month, at best, as being oversimplistic and a bit naive.

Jumping to Conclusions

It’s not the first time in my life I’ve jumped to a conclusion. Another I’ve revisited recently can be succinctly summed up in a sentence from PHP in Action:

Alternatively, we could achieve the same effect with Javascript, but it’s better to avoid Javascript if we can, since some users disable it in their browsers.

Reading this recently initially reinforced my long held belief that Javascript is Bad because some users disable it.

The desired effect mentioned in the quote from PHP in Action is getting submit buttons to generate individual commands where there are multiple submit buttons in a form. The authors go on to suggest solutions in javascript which work where there is already javascript present in the form so they aren’t really saying Javascript is Bad so Don’t Ever Use It.

I first hit the ‘Javascript is Bad’ assumption in accessibility and coding circles in about 2003 when the numbers of users with disabled javascript were about 20% (based on visitors to W3C at the time). As a result of taking it for granted I spent six years not bothering to learn much javascript because it’s Bad.

What a waste!

The Real Lesson

I am quickly working to fill this ridiculous hole in my knowledge, with the understanding that javascript should be used with care, for tasks where it is the best fit and always ensuring that all the functionality of the site is still there if a user should have javascript turned off or uses a screenreader.

The lessons here are ones I’ve taken a while to learn and they are relevant to coding and most things in life, I hope this blog post helps others learn them quicker:

  • Conclusions drawn, even by the ‘wise men’ in a community should never be taken on their own, as gospel.
  • Always check the date of a resource if you can.
  • Do your own tests.
  • Join in discussions and check your view against that of others.
  • Go back and review your own conclusions after time, has anything changed? new techniques or technology been released? did you jump the gun?
  • Never be afraid to admit you would change your mind (even if it’s only to yourself).
  • Never be afraid to try something new.

Is there anything you don’t agree with? have I missed something? what assumptions have you challenged recently (your own or from others)?

Bitwise or bit stupid?

I’ll hold my hand up right now and confess to being bit stupid, I was really disappointed with my score in a recent php proficiency test and most of my downfall was bitwise operators (the rest was array functions I’d never needed to use before and I’ll tackle that in another post).

So what’s all the fuss about?

Continue reading Bitwise or bit stupid?

PHPUK Part 3: Comedy, Chris and Closing

Who do you call… Myphp-busters!

Reeling out of Hank’s Microsoft talk I rushed to get a seat for my ‘must see’ talk of the day Myphp-busters: symphony framework. I’ve been dabbling with frameworks for a while as they seem to be becoming a vital tool to increase productivity (especially important for us freelancers) and aid collaboration and team-working by reducing ownership of code (ie. everyone has a better chance of following the code in that clever widget you just built).
Continue reading PHPUK Part 3: Comedy, Chris and Closing

PHPUK 2009 Part 1: Cutting edge and Community

I was really excited to find I was able to go to the PHP conference in London on the 27th February this year, following a fortuitous set of circumstances and I’m glad to say all my excitement was well founded!

It’s great to be part of such a large friendly community and I was really happy to catch up with folks I’d met at PHPNW and talk about the changes to our industry in the last few months. Despite a global downturn it appears that the world of php development is still above water and in some cases actively thriving. So to the talks…
Continue reading PHPUK 2009 Part 1: Cutting edge and Community

Displaying html code listings your blog

I’ve long admired technical bloggers who spout seemingly reams of code listings to illustrate and support their blog articles, whatever the subject.

My recent forays into testing html5 and reporting the findings has lead me to want to produce my own listings. Really simple I thought, just dump the plain text from the source between two <code> tags and hey presto, one listing. Um… No, not quite that simple. It works fine for css – it’s considered plain text unless found in the <head> of a document between <style> tags. Html, however, is more tricky as the browser wants to render it <code> tags or no <code> tags.

Veteran code geeks may laugh and point at my obvious stupidity but I can honestly say it was only after several frustrating minutes of forum searches that the doh! moment struck and I remembered html entities.

So for anyone else out there bashing their head on this seemingly simple conundrum here’s the solution:

  1. type or paste your html code into your favourite blog software between <code> tags
  2. change every & to &amp;
  3. then change every < to &lt;

If you fancy showing the line numbers as well you can always mark up each line as a line item <li> within an ordered list <ol>.

Simple – now I know that is…

… happy code listing!

Confessions of a conference virgin!

Up until November 2008 I was a conference virgin: no jollies, no hotel booking panic and no development talks. As I’ve been self employed as a website developer for three years I decided it was about time to break the mould, invest the profits and head up to Manchester. Working from home with a small group of local customers can lead to an insular perspective and feeling in a rut, surely the best thing to do is get together with like minded professions? Of course, it seems so obvious but it still took me three years to get there!

So why did it take so long? The first thing most people think of is money; yes conferences can be expensive, but you can make it cheaper if you share cars, book buses in advance, go for b&b or find a friends sofa. Another usual barrier is picking the most relevant event to go to, there’s so many to choose from and some days they all seem to be in the US.

Actually my initial stumbling block was finding out about conferences in the first place. Reading the ‘right resources’ will give you a window onto the whole spectrum of geekups, barcamps, lugs, php*s, but what if you don’t know the ‘right resources’? Twitter helped, following everyone featured in the following list of respected friends was a good start and adding feeds such as Planet PHP and A List Apart to my RSS reader was a huge leg-up too.

So armed with the right information all I had to do was book and figure out how to afford it? Almost – I also had to get over the fear.

I dealt with a few assumptions:

1) I didn’t know anyone, (apart from the lovely person giving me a lift)

2) I didn’t know anything,

3) As soon as I opened my mouth I was going to make myself look a fool.

By following the excellent pre conference run up on twitter and the conference site itself I found out about other people who were going, what they were interested in or looking forward to and where they were travelling from. I picked out talks I wanted to go to and made time to go to the socials – quite easy as a freelance but planning ahead can also help make this possible for the employed too.

Forcing myself to speak to complete strangers brought me up against assumptions 2 and 3. In the end I found the simplest thing to do was to admit I didn’t know how much PHP I knew and say I was there to learn and meet people who knew more. Just let me say this was a good move! By being open to new ideas and admitting I didn’t know as much as I wanted to automatically I avoided looking too much of a fool. Not drinking too much on the Friday night helped but I cannot recommend enough the power of being honest.

I even got the chance to meet some of the speakers and kill an assumption I didn’t even know I had โ€“ they are all very approachable rather than the stuffy elitists I thought they might be.

Once I’d arrived and got over the Friday night social jitters it was time for the actual conference. Although I’ve not been to an event like this before, I’ve heard plenty of horror stories: lost registrations, badly signed venues, schedules run amok and tedious talks. I’m so pleased to say PHPNW08 was none of that!

The whole venue was well signed โ€“ from street to seat, the registration staff and crew were friendly and helpful. the schedule was clearly posted and appeared in the goodie bag. Talks started on time and were thoroughly engaging. Sadly, some talks (particularly the HTML to Drupal ) had little time for questions but everything I attended was well worth going to. If anyone is interested there is a list of the talks I attended at the end of the article.

It was a very full day of intense concentration punctuated by fresh air and coffee but unbelievably worth it. The talks weren’t the only reason for going of course, I wanted to make contact with members of PHPWomen in real life, find out who on earth the talented and vocal LornaJane is, take a look at exhibition stands, complete a brainbench test, see a demo of the Zend framework, talk to recruiters and even come home with offers of new work! Completely unrealistically long list of things to achieve as it turns out ๐Ÿ™‚

I have come away from my first conference with a whole new raft of assumptions:

– I don’t know as much as I want to about PHP, MySQL, HTML5, frameworks, testing, security….

– There are loads of resources out there on the web and in my local area to learn more or meet up with geeks like me such as PHPWomen, phpWM, whatwg, and freelance switch.

– I didn’t miss out on everything just because I wasn’t glued to irc all day

– Freelancing is a wonderful way to work

– I’m actually more of a front end developer

– Women can get exactly where they want to in the industry with hard work and determination (just like anyone else) Lorna and Johanna are just two of the successful developers that I had the chance to meet.

– The absolute best way to kick yourself out of a jaded rut is to get out and meet people, go to a conference, geekup, barcamp, php group in your area (or out of your area for a change)

– phpNW08 was the best choice for a first conference, no question. It was well run, open, friendly, and fired up my enthusiasm for the community and industry where I now feel at home.

I owe all that to the fabulous people behind PHPNW08, organisers and sponsors. A huge thank you to Jeremy (phpcodemonkey) for taking the gamble, the crew for keeping it all running so smoothly, Lorna and Johanna for inviting me into the PHPWomen fold, Smylers for being unfailingly enthusiastic and to Stuart for driving.

I attended (and surprised myself by understanding):

Welcome Keynote: KISS (Keep It Simple, Stupid)
Derick Rethans

Highlighting techniques we all forget in the great web2.0 takeover such as URLs that make human sense and the real place for spaghetti

First Steps with Zend Framework
Rob Allen

An excellent introduction to a sensible alternative to Notebook ++ and indicated just how much I don’t know about frameworks and php development.

From HTML to Drupal in 30 minutes
James Panton & Chris Maiden

A brave and successful live coding based talk that embraced visual teaching rather than discussing abstracts. I’m still not sure about Drupal but I liked the approach.

HTML 5: Whatโ€™s that all about?

Hugely energetic and enthusiastic talk by someone who knows and obviously feels passionately about their subject. Most of my post-PHPNW research so far has been around HTML5, standards and CSS.

Twittex: From idea to live in 7 days

As a freelancer I find I also need to know about the commercial world, cost, promotion and planning. It was great to hear about the development of a new service in the wider business context.

This article can also be found on the PHP Women site at

Hackers – part deux

While updating a number of other sites I also decided to clear out some of the test sites I have on my general hosting. Good move as it happens, I noticed the dreaded ‘1’ folder on my wordpress blog too. It’s usually found in the wp-content folder, nestling above the plugins and themes folders. Luckily there are easy ways to remove said inconvenience and I found them on the bontb website. Bontb, for those who don’t know or are just darn curious (like me!), stands for Blog or not to blog. Thank you Majo!

Hackers – you gotta love em >:[

I generally have a neutral view of hackers, you could say that they come with a territory and are always a risk. Lock it all as tight as you can and ride out the storm of school holidays and study leave.

Of course that all changes when files appear on your server that you think has been locked tighter than a nut. I will admit I don’t look at everyone’s site every day so it didn’t hit my radar until my customer tells me his site is down. (A week after he comes back from holiday. By which time of course, 2 weeks have gone past and there are no logs to check how this happened and for proof.) At this point there is no berating the customer, they didn’t ask to be hacked and they are always right…

So it is time to hate the hacker.
All the time I have to spend talking to the host while they pass the buck and pretend it never happened because there’s nothing they can do anyway,
All the time I have to spend reassuring the customer,
All the time I spend uploading and installing a clean script install to replace the already latest version I had running,
All the time I upload products and attributes and other such things to the database,
All the time I go through the configuration files line by line,
All the time I upload custom text files,
All the time I re-upload the images,
I hate the hacker for trying to grab credit card data that the site doesn’t even accept [grr]

But then I have to laugh, the site is so quiet at the moment that the chances of them getting any results would be nil. There’s no credit card data accepted or stored.

I have to love the hacker who is so incompetant that their injected files do nothing but produce error messages that then cause the customer to call me to say their site is down. If the site had been popular or the customer less on the road it would have been reported same day and then the possibilities for proof and tracking could have been endless.

So although I’ve spent hours putting a site back together, I have to quote Nelson in saying