Linking file

Hi all. I am having a problem linking an include file…

My file structure:

root
head.php

subFolder
myFile.php

To get to the file I have tried everything I can think of. But what I thought should work, isn’t.
In myfile.php I have a line at the top that says require '../head'

But for some reason this line throws an error.

Warning : require(head.php): Failed to open stream: No such file or directory in E:\xampp\htdocs\runes\algiz.php on line 3

Fatal error : Uncaught Error: Failed opening required ‘head.php’ (include_path=‘E:\xampp\php\PEAR’) in E:\xampp\htdocs\runes\algiz.php:3 Stack trace: #0 {main} thrown in E:\xampp\htdocs\runes\algiz.php on line 3

I noticed the line that says

(include_path=‘E:\xampp\php\PEAR’)

and wondering why the PEAR is in there since I have not seen that before.

Anyway, suggestions are greatly appreciated.
Jim

You need to add the filename extension.

require '../head.php'

Sorry about that but I do have the .php extension on the file, and that is correct. I guess that is what happens when you are trying to hurry…

I think it has to be like this. you first need to tell php to go to your sub folder and look for it there
require "../subfolder/myFile.php";

PaganJim, you need to add the code into your PHP such as index.php (using index.php) as an example.

As CodingHelp stated require "../subfolder/myFile.php"; you need to add it like this:

<?php `require "../subfolder/myFile.php";` ?>

Substiture “subfolder” to the name of your folder your php file is in.

Hope this helps.

Dan

Sponsor our Newsletter | Privacy Policy | Terms of Service