Return to Help Center

Welcome to the Bravenet Help Forums. Here you can chat and meet other Bravenet Members. Please do not post advertisements.

Forum: Web Design Discussions
Start a New Topic 
  
Author
Comment
How to call a php file from a file within a folder.

Hi,

I have no problem calling html from an external php from my main website page (index.php) or from other files outside of folders. However, when I make a file within a folder, the same syntax does not work to call the same external php.

I am using the following syntax to call the php file:



When calling this same php file from a file within a folder, I have tried using the following, but it does not work:



What will work?

Re: How to call a php file from a file within a folder.

I noticed that my code is not showing up in my question. hmmm....

Re: How to call a php file from a file within a folder.

Code:

<!--?php include ('http://my_domain_name/includes/header.php');?-->


This was the line of code. All else being equal identical code should work from any html page in the root or any sub folder.

I suspect that there is a.n.other problem with the file in the folder. Upload the same file to both locations and check if they both work.

Re: How to call a php file from a file within a folder.

I found the answer not too long after I posted this. In case anyone else wants to know the answer to this question, this code works when trying to call a PHP file from a sub folder/file:

$path = $_SERVER['DOCUMENT_ROOT'];
$path .= "/includes/nav.php";
include($path);
?>

Of course you would need to change "/includes/nav.php" to whatever your folder/file name is that you are using.


And thank you to all who reached out to help.

Jennifer

Re: How to call a php file from a file within a folder.

Quote: Jennifer Williams
Hi,

I have no problem calling html from an external php from my main website page (index.php) or from other files outside of folders. However, when I make a file within a folder, the same syntax does not work to call the same external php.

I am using the following syntax to call the php file:



When calling this same php file from a file within a folder, I have tried using the following, but it does not work:



What will work?



For anyone wishing to view the code (hidden) just click "Quote" and the code will show.