Jump to content

Recommended Posts

Posted

I'm finding for these to load correctly, I need to include public_html at the front end of the url that the include grabs, otherwise it can't find the file. Is there a way to get around that?

 

Justin

Posted

You should not have to put public_html at the front of your include file statement as long as it is in the same directory. The only time that I put that is if I am a few directories deep and I want to include a file that is in the root directory.

Posted

From the php tutorial section of this forum I found

 

<?php

include $_SERVER['DOCUMENT_ROOT']."/inc/header.php";

?>

 

to make your includes find the the path from the root folder.

 

 

This way I am sure no matter where the page is located,

the path is right.

Posted

You beat me to it, Don. Great job.

 

The other method that I've seen work is to define the root or the path like so

 

define ('PATH', '/this/path/file/dir/');

 

And then you can include it like

 

include PATH . "header_file.php";

 

I did this from memory and didn't test it out. But look up 'define' at www.php.net if you are interested in using it.

Join the conversation

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

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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...