Reputation: 143
I'm trying to set all header inside 1 folder name header.php
So that everytime i can just use
<? php include ("header.php")?>
to set up all my stylesheet, JS and etc... but once i created a new file and create new php try to include my "header.php" it shows this error message
Warning: include(header.php): failed to open stream: No such file or directory in
C:\xampp\htdocs\WebEnt\Certain View File\Register.php on line 5
Warning: include(): Failed opening 'header.php' for
inclusion (include_path='C:\xampp\php\PEAR') in
C:\xampp\htdocs\WebEnt\Certain View File\Register.php on line 5
header.php
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="Picture/SEGI2.png">
<title>EC-Submission</title>
<!-- Bootstrap Core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- Custom CSS -->
<link href="css/custom.css" rel="stylesheet">
<!--Own Customized CSS by Jake-->
<link href="css/WebCustom.css" rel="stylesheet">
<!-- jQuery -->
<script src="js/jquery.js"></script>
<!-- Bootstrap Core JavaScript -->
<script src="js/bootstrap.min.js"></script>
</head>
can anyone provide the easiest solution? Thank YOU
Upvotes: 0
Views: 83
Reputation: 143
I've found a solution also thanks to whoever comment and help me to solve this issue. Here i'll list out how i solve this problem.
Back to "C:\xampp\htdocs\WebEnt\Certain View File\Register.php" and changing the include path via this method
<?php include "$_SERVER[DOCUMENT_ROOT]/WebEnt/HVF/header.php"; ?>
Upvotes: 0
Reputation: 502
To fix the problem with the CSS files, you need to use path
/WebEnt/css/WebCustom.css
or
/css/WebCustom.css
I'm not sure which one is working, but it's easy to test.
The explanation for this is that now the paths are in the HTML-code, which is processed only in browser while showing the page. Thereby the path must be relative to the directory where the server is serving the pages from. When you visit your site, I guess you go to address http://localhost/
, that points to either C:\xampp\htdocs\
or C:\xampp\htdocs\WebEnt\
. That is what you need to take into consideration on the css path.
Upvotes: 1
Reputation: 478
You haven't provided correct path for your header.php file, check in which folder is your header.php and correct its path in include
Upvotes: 1