Salim Almughairi
Salim Almughairi

Reputation: 69

Cannot include my Css files using require or include in my code

I am having some unusual problem with my site. i have inserted all the CSS Files in my header file and i have included it in every php page the below is a php header file that i am including it in every php page. however the content of the header appears but the style is not apearing at all. i have checked the path of both the Css and the include file but i still cannot find the problem.

let me give you you the path details below and maybe you might be able to spot the problem if i did not. the header is located in the includes folder now what i am trying to do is call the header from the admincontent.php that is located in the admin folder.

The css files that are included in the header: localhost/bobs/css/cssfiles....

The Header Path:localhost/bobs/includes/header.php

The file that is calling the Header: localhost/bobs/admin/admincontent.php

<?php require_once("function.php")?>
<!DOCTYPE html>
<html leng ="en">
<head>
<meta charset="utf-8" /> 
<title>ClickTravelStay</title>
 <link href="css/reset.css" rel="stylesheet" type="text/css">
 <link href="css/general.css" rel="stylesheet" type="text/css">
 <link href="css/footer.css" rel="stylesheet" type="text/css">
 <link href="css/form.css" rel="stylesheet" type="text/css">
 <link href="css/admin.css" rel="stylesheet" type="text/css">
 <link href='http://fonts.googleapis.com/css?family=Droid+Sans' rel='stylesheet' type='text/css'>
 <link href='http://fonts.googleapis.com/css?family=Oswald:400,700' rel='stylesheet' type='text/css'>
</head>
<body>
<div id="topHeader" class="Calign"> 
    <a href ="index.php" id="logoFigure">
    <img src="img/repetimg/logo.png" height="60"/ >
    </a>   
    <div class="cBoth"><!-- clear Both--></div>    
    <ul id="nav">
    <li><a href="index.php">HOME</a></li>
    <li><a href="vication.php">VICATION</a></li>
    <li><a href="carrental.php">CAR RENTAL</a></li>
    <li><a href="#">Corporate</a></li>
    <li><a href="deals.php">DEALS</a></li>
    <li><a href="contact.php">CONTACT</a></li>
    <li><a href="about.php">ABOUT US</a></li>
    </ul>

    <ul id="help">
    <li><a href="#">Book online or call: 080099999 Free from a landline</a></li>
    </ul>
</div><!-- END OF topHeader-->

Now the following code is the code of the admincontent.php that calls the header file.

<?php require_once("../includes/header.php");?>
<?php require_once("../includes/connection.php");?>
<?php find_hotel_and_room_forNavig();?>
<div class="cBoth"></div>
<div id="sep"></div>
<div id="content" class="Calign">
<ul id="menu">
             <?php
               Navigation($selected_hot, $selected_rom);
             ?>
             <li><a href="new_hotel.php">+ Add new Hotel >></a></li>
</ul>
<div id="subcontent">
<?php
     echo $selected_hot['hotel_name']."</p>"; 
     echo $selected_rom['room_type']."</p>";
?>
</div><!--end of subcontent-->
</div><!--end of content-->
</body>
</html>

what i don't understand is that when i call the header from the index.php out said the admin folder like this(localhost/bobs/index.php) everything works fine but i cannot refer to the header from the admin folder. is it a bug because from what i see the path is fine unless there is something else that needs to be setup. Remember i can access the content of the header but the style does not display at all. the html comes up as usual but with no style what so ever. thank you very much for your support.

Upvotes: 0

Views: 2964

Answers (2)

Pekka
Pekka

Reputation: 449465

what i don't understand is that when i call the header from the index.php out said the admin folder like this(localhost/bobs/index.php) everything works fine but i cannot refer to the header from the admin folder.

This is working as designed: you are using relative paths. Use absolute paths to your CSS style sheets instead.

Upvotes: 2

Dr.Molle
Dr.Molle

Reputation: 117334

Use an absolute path

/bobs/css/[filename].css

Upvotes: 1

Related Questions