The PHP code in the database must not have opening and closing PHP tags,
just the raw PHP code.
And any HTML must be echoed.
Example:
The code in the database could look like this,
notice that there are no opening or closing PHP tags.
Then your code will work.