Question

I have a code that will check if the user uploaded an image to the database and that image is stored as a blob type. If the user did not upload any image, it will use a default image as a background. I've been trying different kinds of code and these codes are not working here is my code.

$backimage = $row2['back_img'];

if($backimage<=0){
$background = "images/main-wrapper-bg.png";


}
else
{
$background = 'data:image/png;base64,'.base64_encode($row2['back_img']);
}

and here is my css code for the background

body {
margin: 0;
padding: 0;
background: url(<?php echo $background;?>);
background-position:center top;
background-repeat: repeat;

font-family: Arial;
font-size: 14px;

}

No correct solution

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top