Jump to content

Recommended Posts

Hey,

sorry if this has been asked before but i couldn't find it in the search...

but anyway my problem is that my a.php page is in a folder called main in the root...so the url would be http://www.mysite.com/main/a.php

But when I try to have an include like include("includes/z.php"); nothing shows up...the include doesn't seem to show up. Is there anyway I can fix this?

 

P.S. root/main/a.php and root/includes/z.php  those are the locations of the files...so im not sure what im doing wrong.

 

Thank you for your time;

~L

Link to comment
https://forums.phpfreaks.com/topic/61042-help-on-includesnot-linking-corrrectly/
Share on other sites

infact thorp i have a question also

 

i had a script which i moved from one server to another and it stopped working.. it was down to the fact i used

<?php include $_SERVER['DOCUMENT_ROOT'] . '/includes/z.php'; ?>

, which was pretty standard in my code.. instead i used

dirname(__FILE__)."/../includes/z.php"

, which seams to work but is their a "standard" ?

the dirname gives me "/hosted/subs/ulmb.com/i/n/infinitevortex/public_html" without quotes

 

then when i echo it gives me

hosted/subs/ulmb.com/i/n/infinitevortex/public_html/includes/z.php

 

when i put

echo dirname(__FILE__)."/includes/z.php";

 

here is my include

<?php include dirname(__FILE__)."/includes/z.php"; ?>

 

Thank you for your effort thus far

~L

This is how I do it -->

 

On the root of the server I have folder called "element" the folder where all my includes are.

 

This is a page:

 

<?php

// define page elements
$root = "../element/";

// header include
include ($root.'header.php');

?>
<body>

</body>
<!-- HTML BODY END -->

<!-- Footer Include -->
<?php

// footer must be included
include ($root.'footer.php');

?>

 

This is an example. $root is the path name to the root of the server. If you are editing the index you would leave it empty, if its one directory in its ../element and 2 directories in it would be ../../element.

 

This works for me. I hope it works for you.

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.