first off, that... is a scary chunk of code there.
second, the variable `$evnt_cat` has not been declared before you attempt to use it and since your server has error_reporting turned off, you could not see the error it wanted to throw.
the page you took that bit of PHP from (source document) was set up to allow you to use the part of code you had (the 'snippet' of code). the document you're attempting to paste that snippet into (destination document) has not been set up the same way. unfortunately, what you're trying to do is not possible without rewriting a large part if not all of the destination document.