I'm not sure, but I think you change the place in you PHP code from:
[php]<?php
...
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
...
?>[/php]
To:
[php]<?php
...
$result = mysql_query($query) or die('That username is already taken!');
...
?>[/php]
But I don't know for sure so don't quote me on this
