Sunday, 3 April 2011

Trouble with mysql, apache, php5 and codeIgniter

I am working on a new web interface to townguide based on php so it can be used on a low cost web hosting service (rendering will be done by a separate computer).
I am going to use the codeIgniter web framework because it seems simple, and is simiar to django, which I was just starting to get used to.....
Alas getting database access working on my laptop for development was difficult.
I have apache, php5 and mysql all working, but whenever I tried to load the database module of codeIgniter I got a 500 Internal Server error, but no errors in either the apache or codeigniter error logs.   This made debugging difficult.
After much searching on the internet I realised it was because I needed to install libapache2-mod-auth-mysql as well as php5-mysql.
Doing sudo apt-get install libapache2-mod-auth-mysql and re-starting apache made the following trivial mysql db connection work:

$conn = mysql_connect('localhost', 'www', '1234');
if($conn) {
  echo 'Finally connected!!!';
 } else {
  die('Still cannot connect' . mysql_error());
A bit late now, but I think this will also have solved the problem connecting to the database using codeigniter....
Post a Comment