Can’t connect to remote mysql server with php/apache but can through php/cli

Today at work we were migrating some sites to a new server infrastructure with the different services (i.e. php, mysql, mail) spread over different servers.

One problem we ran into whilst setting this up was that php scripts running through apache were having trouble connecting to the mysql server.

What was even stranger though, was the fact that this problem only appeared when the php script(s) were run through apache – running them through the command line / shell worked absolutely fine.

Continue reading

Posted in Computing, Web Servers | Tagged , , , , | Leave a comment

OSCommerce / Paypoint redirects to payment information after paying

I was asked to do some work on an oscommerce site which was accepting payments from paypoint (formally secpay) yet instead of redirecting the user to the “Thank you for your order” page it was sending them to the payment information page, and wasn’t classing the order as being paid for.

After a bit of debugging it turns out the problem stems from the paypoint-secpay merger and the fact that OSCommerce is a poorly supported hunk of junk.

Continue reading

Posted in Programming | Tagged , , , | Leave a comment

Updated textarea maxlength with Jquery plugin

When I first wrote the “Textarea maxlength with jQuery” plugin last year I had no idea how popular it would be – over 70% of the visits to my site since then have been people reading that one post. The problem is, the code there is basically an ugly hack – you copy and paste and you’re done. But if you need to implement the same functionality across a site with slight differences to the functionality, you’d end up with a lot of copy and paste garbage. Continue reading

Posted in Programming | Tagged , , | 9 Comments

Testing Kohana3 with PHPUnit

Unit testing is great, period. It allows you to test different parts of your application independently of the rest of the system.  Any changes that will cause problems elsewhere can be identified almost instantly (if you’re doing it right!).

Up until recently Kohana3 was using a home-grown module for unit testing – It was ok, but lacked some of the more advanced features of independent testing suites – however now the project has now adopted PHPUnit as its official test framework!  PHPUnit is one of the more popular testing suites for PHP, it has full support for FixturesMock ObjectsCode Coverage and a lot of other cool stuff.

The module only requires a few changes to the bootstrap in order to integrate Kohana with PHPUnit, and afterwards you can run tests from the cli, IDE or our custom web runner.  All available tests are loaded from Kohana’s cascading filesystem and can be filtered using PHPUnit’s –group switch.

Go and git it while it’s hot!

Posted in Programming | Tagged , , , , | 4 Comments

How to get Ubuntu to ping a Windows hostname (and vice-versa)

I’m currently running ubuntu server in a virtual machine on my pc, and one of the annoying problems I’ve always had with ubuntu is that it never seems to be able to resolve the hostnames of machines running windows.

After a little bit of digging I found a really simple solution in this forum topic

All you have to do is:

sudo nano /etc/nsswitch.conf

change the line that says

hosts: files dns

to this:

hosts: files wins dns

(order does matter)

finally, you need to install winbind

sudo apt-get install winbind

To enable windows to ping ubuntu you then need to install samba:

sudo apt-get install samba
Posted in Computing | Tagged | Leave a comment

Virtualbox – 1 differencing child hard disks

If you’re getting an error along the lines of “{hard disk} cannot be directly attached to the virtual machine because it has 1 differencing child hard disks”

Then the solution is to delete the virtual machine (but not the hard disk!) and then recreate the machine using the hard disk.

Posted in Computing, Virtualisation | Tagged | 1 Comment

Stretch wallpaper across multiple monitors on Windows

When I first got a second monitor I looked around for quite a while to try and find a solution for stretching a wallpaper across dual monitors – Windows was repeating the first half of the wallpaper on both the monitors.

Continue reading

Posted in Computing | Tagged , | Leave a comment

Can’t Install Drupal? Correct DB info yet no error?

The solution is to make sure that:

Continue reading

Posted in Web Apps | Tagged , | Leave a comment

Who the hell’s matt?

If you actually know me on the interwebs, you may be wondering why the hell the name on this site has changed from alex to matt all of a sudden.

Alex was an alias I used when I first started using the web (back 5 or so years ago). Recently I’ve started using my real name – matt – (it’s definitely my real one!) as a lot of people I know in the real world get really confused when I point them at a site written by an “alex”.

Hopefully I should be writing a few more posts in the weeks to come :)

Posted in Miscellaneous | Tagged | Leave a comment

Host personal SVN projects for free using DropBox

If you’ve ever tried to find an svn host that’s willing to host personal, private projects for free, you’re probably well aware that are practically none. One of the best ones used to be Assembla, until they changed their business model so that only OS projects could be hosted for free.

Other free hosts include beanstalkapp and Spring Loops, both of whom give you at least one repository, 100mb of space and a few user accounts to play with. This is great for one project, but when you start another one / run out of disk space you have to create a new account with a different email address, a different url etc. At the end of the day you’re just wasting time that you could be using to make the next awesome application. Continue reading

Posted in Version Control | Tagged , | 2 Comments