Problem with includes and oragnizing of files - Need advice

Hello, I have a serious problem with includes

So in the past I didn’t have any organizing done when creating a website it was just the root and I throw in my files and a folder for the images. Now I am organizing my files something like this http://www.flickr.com/photos/41987677@N03/4926503042/.
Now in index.php on the root folder I included the top.php, bottom.html and sessions.php as seen on global folder and inside of top.php and session.php are more includes to files like global.css the javascript files and images like logo and background of the top. now everything worked fine on index.php(root) and displayed everything.

Now under the karoobridge folder (index.php) I included the top and bottom files on global now its throwing an error. My question is: is the organization I’m using useless with includes should I stick with just throwing everything on root directory? Can you give me some advice?

Sorry if my explanation is confusing but I think you get the idea.

Yes it just shown me a broken image icon.

No, pointing to /images/ works from any place in the site. Did you try it?

Well puting / doesn’t work when subdirectories are including files above it. So I tried putting $_SERVER[“DOCUMENT_ROOT”] on the img src=“<?php $_SERVER[“DOCUMENT_ROOT”]. ‘/’ ?> images/image.png”> but it does not show the image yet it only shows the alt property of the image.

You’d best show us some of the code you are using. Otherwise this is just guesswork.

index.php (root)

<?php
include(‘global/session.php’);
?>

<link rel=“stylesheet” href=“home.css”>

<script type=“text/javascript”>

$(document).ready(function(){
$(“#karoobridge”).hide();
$(“#karoobridge”).fadeIn(2000);
});

</script>

</head>
<body>
<div id=“main”>
<?php include(‘global/top.php’); ?>

<?php include(‘global/bottom.html’); ?>
</div><!-- main –>
</body>
</html>

//this works fine all images are here

top.php

<div id=“header”>
<div class=“choke” id=“headerChoke”>
<a href=“http://www.ossapp.com/”><img src=“images/imgIncludes/logo.png” alt=“OSS Software Solutions” id=“logo” width=“220” /></a>

</div>
</div>

//I removed the nav since its not a problem the problem is the img when its called from here

index.php (under karoobridge folder)

<?php

include ‘…/global/session.php’;
?>

</head>
<body>
<div id=“main”>
<?php include ‘…/global/top.php’; ?>

<?php include ‘…/global/bottom.html’; ?>
</div><!-- main –>
</body>
</html>

now… the top.php and bottom text and content which does not have an include show up. but the logo in the top.php does not show up

session.php

<?php session_start(); ?>
<!DOCTYPE html>
<html xmlns=“http://www.w3.org/1999/xhtml”>
<head>

<script type=“text/javascript” src=“http://code.jquery.com/jquery-latest.min.js”></script>
<!-- include Google’s AJAX API loader –>
<script src=“http://www.google.com/jsapi”></script>
<!-- load JQuery and UI from Google (need to use UI to animate colors) –>
<script type=“text/javascript”>google.load(“jqueryui”, “1.5.2”);</script>
<script type=“text/javascript” src=“global/nav.js”></script>

<link rel=“stylesheet” type=“text/css” href=“global/reset.css” />
<link rel=“stylesheet” type=“text/css” href=“global/ie.css” />
<link rel=“stylesheet” type=“text/css” href=“global/global.css”>

this is the content of session.php if you are wondering.

so what do you think?

I can’t really interpret all that code, but firstly I would replace all of the include links with the kind of code I first posted.

Also, when you include code on a page, it looks at the rest of the site from where it’s been placed, so you shouldn’t have a link like this in an include:

img src="images/imgIncludes/logo.png

That will always be looking for the images folder as a sub folder of the current page. You should change that to

img src="/images/imgIncludes/logo.png

… that is, with the slash at the front. Then it will always look for images in a the image folder in the site root.

The $_SERVER["DOCUMENT_ROOT"] . bit means that those files will be found no matter where a page is in the site hierarchy.[/QUOTE]

I put that in the index of karoobridge folder to get the top.php, though i got the file the image in top.php didn’t appear (I also used $_SERVER[‘DOCUMENT_rOOT’] for the images) what could be the problem?

All you need to do is link to the include files like this:

<?php include [COLOR="Blue"]$_SERVER["DOCUMENT_ROOT"] . [/COLOR]"/global/top.php"; ?>

The $_SERVER["DOCUMENT_ROOT"] . bit means that those files will be found no matter where a page is in the site hierarchy.