L Posted July 20, 2007 Share Posted July 20, 2007 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 Quote Link to comment Share on other sites More sharing options...
MadTechie Posted July 20, 2007 Share Posted July 20, 2007 try include("../includes/z.php"); Quote Link to comment Share on other sites More sharing options...
trq Posted July 20, 2007 Share Posted July 20, 2007 Bets to use.... <?php include $_SERVER['DOCUMENT_ROOT'] . '/includes/z.php'; ?> Quote Link to comment Share on other sites More sharing options...
L Posted July 20, 2007 Author Share Posted July 20, 2007 <?php include $_SERVER['DOCUMENT_ROOT'] . '/includes/z.php'; ?> that doesn't seem to work, but include("../includes/z.php"); seems to work for me...if i had a file deeper from the root would i just have it like include("../../../z/z.php ~L Quote Link to comment Share on other sites More sharing options...
MadTechie Posted July 20, 2007 Share Posted July 20, 2007 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" ? Quote Link to comment Share on other sites More sharing options...
L Posted July 20, 2007 Author Share Posted July 20, 2007 hmm....the whole ../ thing isn't working now...cause when i go to my index the include doesn't show...i have one file called z.php that is my menu, but now it's all messed up...except in the a.php page because it was specified...any help? Quote Link to comment Share on other sites More sharing options...
MadTechie Posted July 21, 2007 Share Posted July 21, 2007 maybe use the full path /home/public_html/includes or dirname(__FILE__)."/../includes/z.php" Quote Link to comment Share on other sites More sharing options...
L Posted July 21, 2007 Author Share Posted July 21, 2007 both those methods aren't working...here is how i have it <?php include dirname(__FILE__)."/../membership/login.php"; ?> Quote Link to comment Share on other sites More sharing options...
MadTechie Posted July 21, 2007 Share Posted July 21, 2007 if the full path isn't working then theirs a bigger problem.. unless you entered it incorrectly Quote Link to comment Share on other sites More sharing options...
L Posted July 21, 2007 Author Share Posted July 21, 2007 i don't get what the problem can be...and also i rechecked and checked again and nothing seems incorrect Quote Link to comment Share on other sites More sharing options...
trq Posted July 21, 2007 Share Posted July 21, 2007 What is the output of... <?php echo $_SERVER['DOCUMENT_ROOT']; ?> Quote Link to comment Share on other sites More sharing options...
L Posted July 21, 2007 Author Share Posted July 21, 2007 when i echo it all i get is a "/" without the quotes Quote Link to comment Share on other sites More sharing options...
JayBachatero Posted July 21, 2007 Share Posted July 21, 2007 What does this output? <?php echo dirname(__FILE__); ?> Quote Link to comment Share on other sites More sharing options...
L Posted July 21, 2007 Author Share Posted July 21, 2007 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 Quote Link to comment Share on other sites More sharing options...
TheFilmGod Posted July 21, 2007 Share Posted July 21, 2007 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. Quote Link to comment Share on other sites More sharing options...
L Posted July 21, 2007 Author Share Posted July 21, 2007 ...i don't like this method, but its the only one that seems to work...if anyone else can help me thanks, and thanx for the help TheFilm Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.