correct PHP code gives error?
I have correct PHP code that still causes the page to fail. It just stops executing.
It took a while to find the error. I get no error messages the way I use php in WP. I put the answer below. If not relevant the mods just delete it.