I am now even getting 500 error when commenting out the code.
I did not redo everything.
I recreated using the MySQLi recordset WebAssist helper.
It comes out looking exactly as you have suggested it should.
I then uploaded it, and -- even when commented out, just out of curiosity, straight to 500.