- This topic is empty.
July 5, 2014 at 2:23 am #174671
Hi i am having problem with includes. Specifically when including my head which contains the link to the style.css. Although the style.css applies to the index page. It does not for my other .php files which are nested in a folder.
My stylesheet is working for index.php but not dashboard.php. In dashboard.php, just like index.php i am including the overallHeader.php which includes the header.php and the head.php (which contains the link rel to style.css).
However, in index.php for the style to work i am including the overallHeader like this…
<?php include ('includes/overall/overallHeader.php'); ?>
Where as in dashboard.php i am including the overallHeader like this.
<?php include ($_SERVER['DOCUMENT_ROOT']."/includes/overall/overallHeader.php");?>
By using the the document root, it works because i can see the html output just the style is not applied.
In my head.php i am using
<link rel="stylesheet" type="text/css" href="includes/css/style.css">
Is there something i need to change to href, i have tried prefix echoing the document_root, but then the style.css does not work for index.php.
If i check the logs in dashboard.php it shows this.
“NetworkError: 404 Not Found – http://localhost:63342/MYSITE/profile/includes/css/style.css” which is wrong.July 5, 2014 at 3:05 am #174674
Try something like this:
<link rel="stylesheet" type="text/css" href="<?php echo $_SERVER["DOCUMENT_ROOT"].'../includes/css/style.css'; ?>">July 5, 2014 at 3:28 am #174678
Using your method the style does not show up on both dashboard and index.php
But whats weird is there is no console error for style sheet, there is for the script.js but i can fix that later.
Seems odd. Firebug css is still not showing though.July 5, 2014 at 3:32 am #174679
@KKHAN Fixed the above code. I forgot the echo.
Note: you may have to play with
../includes/depending how deep the directories go.
For example, dashboard.php would require
../includeswhere as index.php would require
includes/July 5, 2014 at 3:38 am #174680
This did not work for this reason.
This is what your statements echos out. ive removed the “..” still doesen’t work.
MY includes all have $_SERVER[‘DOCUMENT_ROOT’]. They bring back the html so i assume they are all working. Just the css won’t apply.July 5, 2014 at 3:42 am #174681July 5, 2014 at 3:51 am #174682July 5, 2014 at 3:53 am #174683July 5, 2014 at 3:54 am #174684July 5, 2014 at 4:00 am #174685SenffParticipant
How about this?
<link rel="stylesheet" type="text/css" href="/includes/css/style.css">
Notice the slash before “includes”.July 5, 2014 at 4:01 am #174686July 5, 2014 at 4:04 am #174688July 5, 2014 at 4:09 am #174691
@KKHAN Ok, wait a second. What file are you pasting that in?
It might also help if you paste the path to where the .css file is you’re trying to include and also the path to the .php file you are having trouble getting the css to work in.July 5, 2014 at 4:38 am #174695
I am pasting it in the mysite/includes/head.php file.
Which gets included in the
which gets included in the
mysite/profile/dashboard.php file and
mysite/index.php fileJuly 5, 2014 at 4:49 am #174707
@KKHAN Can you paste what is inside head.php and /overall/overllHeader.php on pastebin? Preferably two separate ones.
If you’re saying that the following is correct but not applying the CSS:
<link rel="stylesheet" type="text/css" href="<?php echo $_SERVER["DOCUMENT_ROOT"].'/includes/css/style.css'; ?>;">
I would ask you to view the page source and click the link that outputs that and tell me if it directs you to the CSS file.
If it does, I’m not exactly understanding your problem. Are you trying to say that it only works within a specific directory and nothing deeper?
- The forum ‘Back End’ is closed to new topics and replies.