Never mind guys. Thank you. I turned on some debugging and it seems my database has a carrage return in the numbers. This causes lots of problems. So it's my code, not Asterisk.