the echo is failing on the empty line after the header information. For the purposes of your testing, replace line 36 with:
echo -a $iif(%result,$v1,$chr(160))
This way it doesn't end up with nothing to echo on a blank line.
If your script only returns 1 or 0, you can be confident in:
if (%result isnum) { we have our number, 1 or 0, stored in %result. do stuff! }
Also make sure your php is sending PHP_EOL (end of line) so mIRC knows the line is done, as your code, even when that echo fails, should continue!
Last but not least.... Questions should go in the forums, not snippets!