Arvgta, at this point you should stop, as you don't know what are you talking about.
Ok, with this topic you got over 100 posts. Happy now?
It started interesting but you don't listen to others. ...
Sorry, my bad,. Your initial query was correct. When using INSERT...SELECT you don't use Values
Ok, so, try running
SELECT progname, code, teid, terms FROM programs WHERE programs.teid NOT LIKE '-'...
Ok, that article you mention is 3 years old. Also, nofollow is supported by google from 2005 and it really does what it says: Doesn't pass link juice (page rank) to linked content.
Both methods serve different versions for user and google (User sees link, google doesn't). This is against google guidelines. Just use rel="nofollow".
You may have cut your ending part of the script. First thought it's indeed, close $ttext string. But as I see, it should also be followed by another call to mail(), after that a closing braket and so...