-2

I have code in index.php

<?php $title ="League of Draven" ?>
<?php require_once $_SERVER["DOCUMENT_ROOT"] . '/inc/head.php';?>
<?php require_once $_SERVER["DOCUMENT_ROOT"] . '/inc/menu.php';?>
<?php require_once $_SERVER["DOCUMENT_ROOT"] . '/inc/footer.php';?>

in head.php

<!DOCTYPE html>
<html>
<head>
<title> <?php print $title ?></title>
<link rel="stylesheet" type="text/css" href="/css/style.css"/>
<script src="http://code.jquery.com/jquery-1.11.2.min.js"></script>
<script src="http://code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
</head>
<body>

when i try to open in my browser i find this error:

 Warning: require_once(C:/xampp/htdocs/inc/head.php): failed to open stream: No such file or directory in C:\xampp\htdocs\Myshop\index.php on line 6

 Fatal error: require_once(): Failed opening required 'C:/xampp/htdocs/inc/head.php' (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\Myshop\index.php on line 6
Arsal Ali
  • 978
  • 3
  • 20
  • 54
Ayaz
  • 53
  • 1
  • 1
  • 7
  • 2
    I dont see a `require_once` in your example. At least show the relevant code or we cannot help we are not **clairvoyant** – RiggsFolly Apr 08 '16 at 11:45

1 Answers1

0

I am guessing you have not created a Virtual Host for this project, so the $_SERVER["DOCUMENT_ROOT"] will be pointing at C:\xampp\htdocs\ and not C:\xampp\htdocs\Myshop

To avoid this you can use the following which says require from the inc folder below where I am currently running this code from whereever that may be

<?php 
    $title ="League of Draven"
    require_once './inc/head.php';
    require_once './inc/menu.php';
    require_once './inc/footer.php';
RiggsFolly
  • 89,708
  • 20
  • 100
  • 143
  • thats not working too. I have created a folder Myshop (index.php file here) in htdoc folder. In Myshop i have created another folder inc in which i have placed head.php file. – Ayaz Apr 08 '16 at 12:23
  • See amended answer – RiggsFolly Apr 08 '16 at 12:39