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

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

In the above the conf.php


now, here is the index.php from the template

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

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:


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
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

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

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.