Jump to content


PHP navigation ruining background images


14 replies to this topic

#1 Matt L

    Young Padawan

  • Members
  • Pip
  • 272 posts
  • Gender:Male
  • Location:Newcastle

Posted 16 August 2006 - 01:25 PM

With the PHP navigation system I have is not showing the background images:
<?php
		$val = $_GET['id'];
		$val .= ".php";
		$dirty = array("..");
		$clean = array("");
		$val = str_replace($dirty, $clean, $val);

	if (isset($_GET['id']))
	{
		if (file_exists($val))
		{
			include "$val";
			}
		else
		{
			echo("File not found");
			}
	}
	else 
	{
		include "shownews.php";
		}
?>

It doesn't show background images from the CSS. Any ideas how I can fix this?

#2 Hayden

    P2L Jedi

  • Members
  • PipPipPip
  • 716 posts
  • Gender:Male
  • Location:Texas

Posted 16 August 2006 - 01:54 PM

can we see the code in it's entirety (HTML, PHP AND CSS)?

is there a page link or screenshot as to what exactly it is doing?

#3 Matt L

    Young Padawan

  • Members
  • Pip
  • 272 posts
  • Gender:Male
  • Location:Newcastle

Posted 16 August 2006 - 01:56 PM

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="description" content="The online portfolio of Matthew License">
<meta name="keywords" content="Portfolio, Web Services,">
<meta name="author" content="Matthew License">
<link rel="stylesheet" type="text/css" href="/style.css" />
<title>The Online Portfolio of Matthew License</title>
</head>

<body>
<div id="header">
  <div align="center">
	<div id="headerimage"></div>
	<div id="navstrip">
	  <div class="navblock">	
		<a href="http://www.matt-license.com">Home</a>
	  </div>
	  <div class="navblock">
		<a href="/about/">About</a>
	  </div>
	  <div class="navblock">
		<a href="/portfolio/">Portfolio</a>
		<div>
		  <a href="/portfolio/templates">Site Templates</a>
		</div>
		<div>
		  <a href="/portfolio/sites/">Web Sites</a>
		</div>
		<div>
		  <a href="/portfolio/photos">Photography</a>
		</div>
	  </div>
		<a href="/contact/">Contact</a>
		<a href="/links/">Links</a>
	</div>
  </div>
</div>
<div align="center">
  <div id="main">
	<?php
		$val = $_GET['id'];
		$val .= ".php";
		$dirty = array("..");
		$clean = array("");
		$val = str_replace($dirty, $clean, $val);

	if (isset($_GET['id']))
	{
		if (file_exists($val))
		{
			include "$val";
			}
		else
		{
			echo("File not found");
			}
	}
	else 
	{
		include "shownews.php";
		}
	?>
	<hr />
	<div class="news">
	  <div class="newstop">Advertisements</div>
	  <br />
	</div>
  </div>
</div>
</body>
</html>
html {
margin:0px;
padding:0px;
}

body {
margin:0px;
padding:0px;
background:url(http://www.matt-license.com/images/mainbg.png) repeat #87987e;
font-family:Verdana, Arial, Helvetica, sans-serif;
font-size:11px;
color:#000000;
}

a:link, a:visited {
font-family:Verdana, Arial, Helvetica, sans-serif;
font-size:11px;
color:#000000;
text-decoration:none;
}

a:hover, a:active {
font-family:Verdana, Arial, Helvetica, sans-serif;
font-size:11px;
color:#000000;
text-decoration:underline;
}

hr {
background-color:#b6d9a3;
color:#000000;
height:1px;
margin:5px;
}

/* ID's */

#header {
width:100%;
background:url(http://www.matt-license.com/images/topbg.png) repeat-x #5b7051;
height:139px;
text-align:center;
}

#headerimage {
background:url(http://www.matt-license.com/images/header.png) no-repeat #5b7051;
width:480px;
height:116px;
}

#navstrip {
height:23px;
width:394px;
text-align:center;
padding-top:3px;
}

#navstrip a {
font-family:Verdana, Arial, Helvetica, sans-serif;
font-size:11.5px;
color:#000000;
text-decoration:none;
}

#navstrip a:hover {
text-decoration:underline;
}

#main {
padding:5px;
width:483px;
height:100%;
background:#607d52;
font-family:Verdana, Arial, Helvetica, sans-serif;
font-size:11px;
color:#000000;
}

/* Classes */

.news {
background:#7fa36b;
width:480px;
font-family:Verdana, Arial, Helvetica, sans-serif;
font-size:11px;
color:#000000;
text-align:left;
}

.newstop {
background:#91be79;
font-family:Verdana, Arial, Helvetica, sans-serif;
font-size:12px;
color:#000000;
text-align:left;
padding:2px;
}

.news img {
margin:3.5px;
}

.navblock {
width:125px;
display:inline;
}

.navblock div {
display:none;
}

.navblock div:hover {
background:#91be79;
color:#000000;
display:block;
border-top:1px #FFFFFF solid;
border-bottom:1px #FFFFFF solid;
height:20px;
}

.noborder {
border:0px;
}
Click here to see what it's doing

Edited by DJL2K, 16 August 2006 - 01:57 PM.


#4 Matthew.

    Official Spammer .Matt

  • Members
  • PipPipPipPip
  • 2,749 posts
  • Gender:Male
  • Location:England

Posted 16 August 2006 - 02:33 PM

Could be the css, trying taking out "repeat" from the background property. Its not needed if you want it to repeat it on both x&y axis.

#5 Matt L

    Young Padawan

  • Members
  • Pip
  • 272 posts
  • Gender:Male
  • Location:Newcastle

Posted 16 August 2006 - 02:46 PM

It was all fine before I put the navigation in.

#6 Wybe

    Jedi In Training

  • Members
  • PipPip
  • 399 posts
  • Gender:Male
  • Location:the Netherlands
  • Interests:Graphic design, digital and traditional, street style, graffiti, guerilla drawing, typography, coding, sex

Posted 16 August 2006 - 02:57 PM

Work from there. See what the HTML output is and where what is causing the error. If that doesn't work, take out the PHP navigation again and build it up again. Continue to build it up again from simple to perfect and if, underway, you notice your background suddenly stopped working you know what change caused it to happen (and you then know where your error is).

Trick not only applies to getting your bg to work but just about every problem you can ever come across

#7 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 16 August 2006 - 04:18 PM

Looks like the part your showing us is working just fine to me. The only potential problem i see is with shownews.php (it's outputing some html, but no text really).

Now, if this is a CSS/HTML problem, it belongs in a different category. If you're having a problem with your backgrounds, it's probably because the images don't exist:
www.matt-license.com/images/topbg.png

#8 Matt L

    Young Padawan

  • Members
  • Pip
  • 272 posts
  • Gender:Male
  • Location:Newcastle

Posted 17 August 2006 - 02:37 AM

They were fine before I put my navigation script in though. I understand what it's doing - it's calling the images as if it's at .php file - but I don't know how to fix it. And shownews.php isnt showing anything because I haven't added any news yet.

Edited by DJL2K, 17 August 2006 - 02:38 AM.


#9 Matthew.

    Official Spammer .Matt

  • Members
  • PipPipPipPip
  • 2,749 posts
  • Gender:Male
  • Location:England

Posted 17 August 2006 - 06:24 AM

Surely if the images folder doesnt exist.....

http://www.matt-license.com/images/

No images :love:

#10 Matt L

    Young Padawan

  • Members
  • Pip
  • 272 posts
  • Gender:Male
  • Location:Newcastle

Posted 17 August 2006 - 06:30 AM

It does though. That's what I don't understand.

#11 Matthew.

    Official Spammer .Matt

  • Members
  • PipPipPipPip
  • 2,749 posts
  • Gender:Male
  • Location:England

Posted 17 August 2006 - 06:36 AM

aha...ok,your using mod_rewrite, right? :love: COuld be forcing it /images/ into whatever you have in the rule.

try changing /images/ to /images/anotherfolder/ see what works. If it is the rewrite rule that should stop it.

#12 Matt L

    Young Padawan

  • Members
  • Pip
  • 272 posts
  • Gender:Male
  • Location:Newcastle

Posted 17 August 2006 - 06:41 AM

Still nothing. And before you ask - I have updated the stylesheet.

#13 Demonslay

    P2L Jedi

  • Members
  • PipPipPip
  • 970 posts
  • Gender:Male
  • Location:A strange world where water falls out of the sky... for no reason.
  • Interests:Graphic Design, Coding, Splinter Cell, Cats

Posted 17 August 2006 - 12:22 PM

Post your rewrite rule, it shouldn't be forcing just '/images' into the rewrite. It should only force it into a variable if it has a trailing slah after the text if you wrote your rule correctly.
And it should be written correctly because using a line like this would cause an internal error (I've ran into that hundreds of times trying that).
RewriteRule ^(.+)$ /index.php?id=$1 [nc]

You should have it like this.
RewriteRule ^(.+)/$ /index.php?id=$1 [nc]


#14 Matthew.

    Official Spammer .Matt

  • Members
  • PipPipPipPip
  • 2,749 posts
  • Gender:Male
  • Location:England

Posted 17 August 2006 - 01:00 PM

I think it has to be something to do with the rewrite...as if you enter:

http://www.matt-license.com/images into the url box and load, it redirects to:

http://www.matt-license.com/images/ which confuses me.

Before we go cocking about with things that may be of no use try removing your .htaccess file temporarily and then try it. That will tell us if its the rewrite.

Edited by .Matt, 17 August 2006 - 01:02 PM.


#15 Matt L

    Young Padawan

  • Members
  • Pip
  • 272 posts
  • Gender:Male
  • Location:Newcastle

Posted 17 August 2006 - 01:06 PM

Thanks Demonslay! That fixed it.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users