Jump to content

What would be the root of this path


Shadowing

Recommended Posts

hey guys im still having a issue with using the root path when requiring external files. So i can use one path and never have to worry about this issue.

 

require("/functions/function_battle.php");

the file is located here

C:\Software\XAMPP\xampp\htdocs\System_Lords\functions\function_battle.php

 

i dont understand (include_path='.;C:\Software\XAMPP\xampp\php\PEAR')

im suppose to be including the php folder or something?

 

 

Fatal error: require() [function.require]: Failed opening required '/functions/function_battle.php'
(include_path='.;C:\Software\XAMPP\xampp\php\PEAR') in
C:\Software\XAMPP\xampp\htdocs\System_Lords\include\battle.php on line 2

 

Link to comment
Share on other sites

Alright this is the way this is going but yah its the last file in the chain that is causing the issue.

all my other pages work fine on my site that is requring battle.php and then having battle.php use function_battle.php.

 

this is the page im viewing

C:\Software\XAMPP\xampp\htdocs\System_Lords\messages\inbox.php

 

then on that file im including this file "which is a menu"

require("../menu.php");

C:\Software\XAMPP\xampp\htdocs\System_Lords\menu.php

 

and on the file above "the menu" has this file included

 include_once("/include/battle.php"); 

C:\Software\XAMPP\xampp\htdocs\System_Lords\include\battle.php

 

and on the file above "battle.php" has this file included

require("/functions/function_battle.php");

C:\Software\XAMPP\xampp\htdocs\System_Lords\functions\function_battle.php

 

 

Link to comment
Share on other sites

Alright this is the way this is going but yah its the last file in the chain that is causing the issue.

all my other pages work fine on my site that is requring battle.php and then having battle.php use function_battle.php.

 

this is the page im viewing

C:\Software\XAMPP\xampp\htdocs\System_Lords\messages\inbox.php

 

then on that file im including this file "which is a menu"

require("../menu.php");

C:\Software\XAMPP\xampp\htdocs\System_Lords\menu.php

 

and on the file above "the menu" has this file included

 include_once("/include/battle.php"); 

C:\Software\XAMPP\xampp\htdocs\System_Lords\include\battle.php

 

and on the file above "battle.php" has this file included

require("/functions/function_battle.php");

C:\Software\XAMPP\xampp\htdocs\System_Lords\functions\function_battle.php

 

 

 

then if is the battle.php that is calling the function battle and this file is in C:\Software\XAMPP\xampp\htdocs\System_Lords\include

you will need to go back one folder to find the file

 

try

require('../functions/function_battle.php');

 

Link to comment
Share on other sites

alright I get this when I use echo_file_; which it didnt tell me anything I didnt know.

so is there away to put a constants in the require path?

C:\Software\XAMPP\xampp\htdocs\System_Lords\functions\function_battle.php

 

I was reading some stuff online and is there a way where i can add this to the require file then?

 

require("/function_battle.php");

 

I was reading a site that says i can do something like this but it doesnt work for me

 

include(dirname(__FILE__).'/function_battle.php');

Link to comment
Share on other sites

Set a constant with your root location. Then address all of your included files by the root.

 

//in your config file.
DEFINE('ROOT_DIR','C:/Software/XAMPP/xampp/htdocs/System_Lords/');

//in your other files
require(ROOT_DIR . 'functions/function_battle.php');

 

 

 

Link to comment
Share on other sites

PHP's filesystem functions work with a filesystem path, not a url path.  In a filesystem path, the root (/) references the root of the drive, which in your case is C:\.

 

So when you do require('/function_battle.php') you are attempting to include the file located at C:\function_battle.php

 

You need to either use a relative path or define a constant to your site's root directory and use it as a prefix when including files.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.