what is the problem exactly? that looks fine to me, although you don't need quote marks surrounding $err_msg[$i].
maybe it would help if you pasted the rest of your phplib template-related code, and double check the spelling of block names in your templates - i've often found typos in mine. 😉
andy.