Hi Guys,
I am trying to change the background image on my site dynamically using the page ID. I have put the PHP together and the image URL generated is correct but no image appears.
Other background images in the same style sheet seem to be ok and the CSS generated looks fine.
I have tried with and without output buffering but no joy. I have also tried reletave and explicit URLS.
It seems that it can not find the image even though the CSS looks correct, Also, if I copy and paste the generated URL from the CSS an to a browser it finds the image straight away.
Here is the PHP code I used.
<?php
ob_start();
$id=$_GET[’id’];
$filename = ’/assets/templates/default/images/’ . $id . ’.jpg’;
if (file_exists($filename)) {
$image=$id . ’.jpg’;
} else {
$image=’about.jpg’;
}
echo"
body
{
margin:0;
padding:0;
font-family:verdana;
font-size: 12px;
color:#ffffff;
background: #ccc;
background-image: url(
http://www.mysite.com/assets/templates/default/images/";
echo $image;
echo ");
/*background-repeat: repeat-x;*/
background-repeat:no-repeat;
/*background-position:bottom center;*/
}";
ob_end_flush();
?>
Here is the CSS generated
body
{
margin:0;
padding:0;
font-family:verdana;
font-size: 12px;
color:#ffffff;
background: #ccc;
background-image: url(
http://www.mysite.com/assets/templates/default/images/about.jpg);
/*background-repeat: repeat-x;*/
background-repeat:no-repeat;
/*background-position:bottom center;*/
}
Any ideas? this is really driving me nuts so any help would be really appreciated.