Css not loading with an include

I have a problem including a file which in itself has a css style this is my index file


<?php
require_once ('restricted/includes/configuration/conf.php');
include ($template);
?>

In the above the conf.php


<?php
$template_name="basic";
$template="restricted/templates/site/$template_name/index.php";
?>

now, here is the index.php from the template


<!DOCTYPE HTML>
<html>
	<head>
		<link rel="stylesheet" type="text/css" href="css/main.css" media="screen" />
	</head>
	<body id='body'>
		<div id='generalcontainer'>
			<div id='header'>
				<div id='logo'>
				</div>				
			</div>
			<div id='menu1'>
			</div>
			<div id="sidebar-left" class="left">
				Hello
			</div>
			<div id="main-content">
				Hello
			</div>
		</div>
		<div id='footerfixed'>
			<?php echo '&copy; Coatlcalli ';echo date('Y');echo', Todos los Derechos Reservados';?>
		</div>
	</body>
</html>

now, the problem is that when I include the index.php from the tempate in the index of the site all the text is showned but the css style is not loading, does anyone know what I am doing wrong? :frowning:

$template=“restricted/templates/site/$template_name/”;

That… is a directory. Not a file. You forget to put something like… main.css on the end?

EDIT: Okay I misread it.

The file is loading in / rather than the directory that you think it is. Change your href in the HTML to /restricted/templates/site/basic/css/main.css

you were right about $template=“restricted/templates/site/$template_name/”; it should be
$template=“restricted/templates/site/$template_name/index.php”;
I have it that way is just that I was trying different things and that is why it was different.
Now about the directory change that you mentioned, I tried it and it does not work, still, loads everything else but the stylesheet, if I open the page with firebug it also tells me that it does not find any styles

Does /restricted/templates/site/basic/css/main.css exist?

Yes, here is the structure

maindir
index.php (main index)
/restricted/templates/site/basic/index.php (template index)
/restricted/templates/site/basic/css/main.css

when I open template index the template loads finewith the styles and everything but when I open the main index which has an include for the template index only the text within the template index is loaded and the styles are not found or not loaded

Is this page somewhere you can link us to? Kind of hard to diagnose the problem without making basic checks.

I have it on my computer, I will upload it to a free host and post the info.

I uploaded it to a host and everything works, it looks like my problem is with my localhost, I will check what is it

Thank you for your help

anyway, why do I have to add the full path, shouldn´t it work with css/main.css?

It’s order of activation.

The client requests /index.php
Your PHP script runs at / level.
Your PHP script executes an include at the style level.
That include is all well and good - but the style sheet isnt loaded by PHP.
The HTML goes out to the client’s browser.
The Client’s browser sees ‘css/main.css’, and because it’s running at the / level, the file must be at /css/main.css. The client’s browser then goes and gets that information.

Can you view source the page to see what URL is being used to load the CSS. Also, you’ve mentioned that you use FireBug, open up the Net panel in Firebug and reload the page. See if there are any 404 errors.