It's happening because your CatLinks table contains a lot of entries that shouldn't be there (ie. contains references to Links that don't exist). I've updated the code (your copy too) to get around that problem; however, you should really fix this.
Adrian
Adrian