Take Two

So, after starting this blog with hopes of documenting anything I found useful and to start to build a personal knowledgebase, I pretty much just left it alone. It popped into my head again today that it would be a useful thing to have. I had completely forgotten about the blog, so was a nice surprise to see that the work to set it up was already done!

Originally I had also intended to use the site as a sort of journal for any projects I am working on, and I still think this would be useful for a few reasons. I can post anything I found tricky to figure out so when I come across the same thing again I should hopefully be able to save myself some work, and maybe even the same for anyone who might find their way here. I also think that if I can get into the habit of posting then it might help keep some motivation going.

Unfortunately I completely lost interest in the last project I was starting on, but I may come back to this at a later time.

Current Projects

At the moment I am working on a couple of things, one is to do with my work/career and the other is more for fun.

Cisco CCNA Certification

So, this is the work one. I am studying toward CCNA Switching and Routing certification. I am very much interested in networking, and my job involves some networking work.

I have been trying to study this on and off for the last year, but really need to knuckle down and pick up some momentum with it and see it through.

Android Game Development with Unity

This is the fun one. I have recently started getting to grips with developing games using Unity, and have been really enjoying it. I have an idea for a game and have been working on it, learning as I go, and it is starting to take shape nicely.

I’ll (hopefully) post anything to do with these projects that I think could benefit someone else or that I think I would want to document for myself.

Project: Online Football Manager Game


When I was a kid I was used to play fantasy football (soccer) type games with my mates. This usually involved picking a team to “manage” (really there was no managing involved :) ), setting up the fixtures and rolling dice decide the scores.

Years ago, when I first started getting interested in programming and discovered QBasic, the first thing I did was begin to write a football match simulation, which evolved into various tools which I used to run an online fantasy football management game, where “managers” (real people who signed up and took over a team) could set their own lineups, tactics, buy and sell players and renew player contracts. That was pretty much the extent of it then, but I really enjoyed creating all of this.

Eventually my programming noobness got the better of me. If I remember rightly, I ran into an issue in QBasic where I had reached the limit allowed for one file (or something like that). I had put all my functions into one file, and I assume I should have been grouping functions together in their own sub files. Anyway, it seemed like a big job to me at the time to fix all of this and I put the project aside.

I’m a little less of a noob now (although still very much an amateur), and there’s certainly more info on the web that’s much more easily obtainable than it was then. I’ve thought many times over the years about resurrecting this project, but with a lot more to it. I’d like to write something similar from scratch and to be run solely from the web, using PHP and MySQL.

At the same time I am trying to better my programming skills, and one thing I’d like to do is move toward OOP. I’ve read a bit about using a PHP framework, and that it should make things easier and faster to code. With this in mind I’ve decided to build this project on CodeIgniter. Finally I’ll be delving into using jQuery for some snazzy widgets and effects.

The Idea

The basic idea of the site is that site users would manage their own football club.

  • They will be in charge of their team selection, tactics and training
  • Buying and selling players, as well as renewing contracts
  • Participate in a league and various tournaments
  • Manage staff
  • Build and maintain their stadium

Each week there would be a couple of league matches, and any cup matches they are involved in. These matches will be able to be “watched” live. That is, the match simulation will generate commentary and events which will be show on a match screen to give the feel that the game is happening live.

At the moment these are the basics I’d like to get into a working state.

The game will be similar to other such sites already up and running, and that seem quite popular (ie. Hattrick and goalunited).

I’ll likely be posting progress as I develop this.

CodeIgniter Database Connection Error

I have started learning how to use the PHP framework CodeIgniter. I’m not a professional coder, but I have dabbled with PHP and various other languages over the years.

As I’m new to the framework, the first order of business was to follow the tutorial to setup a basic application using CodeIgniter. I thought that this would be a fairly quick and easy thing to follow and then I could get on to playing about with it further. About 5 hours later and I finally got to the end of the tutorial with the sample app in working order. This post describes the first issue I came across and how I eventually resolved it.

The Problem

So, I had setup my database and configured username, password and database name correctly in the application/config/database.php file but was getting the following error when trying to access it from the CodeIgniter app.

A Database Error Occurred
Unable to connect to your database server using the provided settings.
Filename: core/Loader.php
Line Number: 346

I double-checked and triple-checked my database settings, and even setup a quick plain PHP test script to make sure I could connect to it and retrieve results successfully, which worked fine.

The Solution

After hours of reading posts from people with similar issues and trying various things, checking and re-checking all my settings etc., the following change fixed it for me.

In application/config/database.php change…

$db['default']['pconnect'] = TRUE;


$db['default']['pconnect'] = FALSE;

It seems to me that some web hosts maybe don’t like persistent database connections, and I guess my host is one of them!

Other Useful Information

Also worth mentioning here is a nice bit of code to add to the end of your application/config/database.php file to help troubleshooting database connection issues. In my case it actually connected without a problem (which at least confirmed that my connection settings were fine), but I read of others who found it very useful. Note that I didn’t write this myself, I found it on a few different posts from different people so not sure who to give credit to.

echo '<pre>';
echo '</pre>';

echo 'Connecting to database: ' .$db['default']['database'];
  or die('Cannot connect to the database because: ' . mysql_error());
  mysql_select_db ($db['default']['database']);

echo '<br /> Connected OK: '  ;
die( 'file: ' .__FILE__ . ' Line: ' .__LINE__);

Using this code you should be able to pinpoint where your connection issue lies.


Before I start posting random, potentially totally unrelated stuff here I guess I’d better give a brief introduction on why I created the site.


Quite often I have found that I spend a lot of time trying to figure out even the smallest problems that I come across while working, learning or even playing! Most of the time it’s something simple that is stopping me from carrying on whatever it is that I am trying to do.

I usually google these things hoping to find a quick solution but can end up spending hours sifting through different websites, forum posts and blogs before I eventually figure out how to fix whatever it is I am having trouble with.

These are the sorts of things I would like to post about here in the hopes that I can save other people that lost time and frustration by combining my experience with all the info I have found on that particular issue in one place.

I also tend to forget these things after a while even after all the time and effort spent to figure them out, so when I come across the same issue I have to work it all out again. So this site can serve as a sort of personal knowledgebase for myself at the very least.

Hopefully anything I write here can be of use to someone!


Another reason for the site is that I may post progress updates to do with any projects I might be working on. This could be web/programming stuff, or even gaming related. More than anything I hope posting updates might help keep me interested in whatever it is that I’m doing!