You could try moving the background style to the body in html like this:
<html>
<body style="background-image:url(<?php echo $background;?>)">
blah blah
</body>
</html>
If this doesn't work, try echo $background
, right after the if/else thing. Post here what it outputs.