Forum Moderators: not2easy

Message Too Old, No Replies

Same page, different results

background image displays on one host, not on another

         

rendaw

2:19 am on Oct 1, 2009 (gmt 0)

10+ Year Member



Hello,
I have a page that I was working on offline (I'm using linux) with Apache 2.2.13. I've pruned the page down significantly searching for the problem, but basically, I have a single div. I set the div's height and width and a background image, relative to the document root.

On my offline LAMP setup, the background image displays in Firefox fine. Using the same Firefox, with the same directory structure, and the same files, but using the online server, the background image does not display.

Hovering the image url as displayed in Firebug, the image appears, so the image location isn't wrong. I tried Safari and Opera in Windows and Safari alone displays the background image.

I feel like I must be missing something unbelievably basic, but it has yet to present itself to me.

Here's the HTML:


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>exampe</title>
<link rel="stylesheet" type="text/css" href="/test2.css" />
</head>

<body>
<div id="background">&copy;
</div>

</body>
</html>

And here's the CSS:


div#background
{
width: 640px;
height: 500px;

background: url('/images/front/spried.png') no-repeat center bottom;
}

I tried it without single quotes in the url, and without the leading slash, among other things.

If anyone has any clues or ideas I might be able to pursue, I would greatly appreciate it.

[edited by: swa66 at 8:21 am (utc) on Oct. 1, 2009]
[edit reason] specifics removed [/edit]

D_Blackwell

3:04 am on Oct 1, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In a test environment I see no problems. However, live on the server an error is generated;

Parse error: syntax error, unexpected T_STRING in /home/.identifier/d_blackwell/example.com/xhtml-issue.html on line 1

I wonder if the DTD, specifically the xml prologue is an issue? Remove the prologue line and test.

<?xml version="1.0" encoding="UTF-8"?>

Of course, if not served properly, the HTML is probably a better choice

Note: The <title> contains a specific identifier to the website in question and I can see that the page (at least the home page) is not rendering. It could be removed by a moderator.

Guide to Posting...

3. Remove any specifics, email addresses or passwords

Please make the posted code as generic as possible and remove or change specifics that identify your site...

rendaw

3:30 am on Oct 1, 2009 (gmt 0)

10+ Year Member



Ack, yes, sorry. I tried to check for urls, etc, but it seems like some escaped my grasp. It seems I am also not able to edit my post?

I assume the line you're talking about is the <?xml ?> one? I just tried that and the results were the same. I also got rid of the "xmlns" property, since that was the default and I might have mis-typed it or something.

That error looks like a PHP error - what diagonistic did you do to get that?

The code is now:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<link rel="stylesheet" type="text/css" href="/test2.css" />
</head>
<body>
<div id="background">&copy;
</div>
</body>
</html>

Do you think it is a server setup issue? I could contact tech support if that is true... but I thought since the source displayed in the browser was the same online/offline (I diff'ed them) the browser would handle them exactly the same.

swa66

8:40 am on Oct 1, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The xml preamble will cause mainly trouble for IE6 throwing it in quirks mode, but is in fact OK.
Now that throw IE6 back into the dark ages is a problem if you need to suport IE6, so most learned to do without the xml preamble.

@rendaw
Removing the namespace definition in xhtml is however not the right move IMHO, it should be there, while IE (all versions) still don't support namespaces, other browsers do in fact support it.

Try using a validator to make sure your code is valid.
[validator.w3.org...]

To find your problem:

Check for mime-type issues.
Locally a file format is recognized differently than when the file is served by a http server.
The mapping of extension to mime-type in apache is done by a mime.types file in the conf directory, check that it has image/png for png files.
And check that your file is in fact a png encoded file if you name it png and have that configuration.

Also clear your caches.

@D_Blackwell:
If you get a php error on the preamble, it means the server is setup to parse PHP on the short <? tag as well as the longer <?php version. php.ini should be able to turn that off if your do not needed in the rest of your site.
What you need is:
short_open_tag = Off

rendaw

3:27 am on Oct 2, 2009 (gmt 0)

10+ Year Member



Okay, thanks for your assistance. As it turns out, the PNG was broken, so your idea was spot on. I guess, with my shoddy internet connection and the semi-frequent server outages at my provider, the transfer got cut off. And, as it happens, it got cut off repeatedly on all of my background images (perhaps because they are much larger than icons and such?).

And thanks for the suggestion about the the XMLNS. I thought that it was a default, rather than a fallback. I fixed that too.

Anyways, thanks again. Not fixed yet, but with perseverence, maybe.