Welcome to WebmasterWorld Guest from 54.166.54.215

Forum Moderators: coopster & jatar k

Php include above Directory

   
4:47 pm on Feb 9, 2014 (gmt 0)

5+ Year Member



I'm having a mental block currently.

forgetting how to do this..

<?php
include('linx.html');
?>


works.

but trying to include a file that's in a directory above it won't.

<?php
include('/new/linx.html');
?>


i've even tried the following extra without success either

<?php
include('./new/linx.html');
?>

<?php
include('../new/linx.html');
?>

<?php
include('new/linx.html');
?>

<?php
include('/var/www/vhosts/sitedomain/new/linx.html');
?>




:-(
5:12 pm on Feb 9, 2014 (gmt 0)

5+ Year Member



I figured out an alternate route.

Next thing I need to do is make this php include file listen to the javascript around it, so that the file embeds within the borders specified within javascript. Otherwise the file just opens across the whole page.

If I can't accomplish this with mixing javascript along with php, i'm willing to accept an alternative.

Basically I just want to lower the width in which this file opens up to. Maybe <table> elements would be better?
6:03 pm on Feb 9, 2014 (gmt 0)

WebmasterWorld Administrator brotherhood_of_lan is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



try "echo getcwd();exit(0);" just before the include to see that the current working directory is the one you expect it to be. Also turn error and warnings on to see what PHP says about it.
6:53 pm on Feb 9, 2014 (gmt 0)

5+ Year Member



The OP solution should be:

<?php
include('../linx.html');
?>

"Include 'linx.html' from the directory immediately above
the current directory ( '../' ).

. . . unless I'm reading the OP all wrong.
Jonesy
8:26 pm on Feb 9, 2014 (gmt 0)

5+ Year Member



thx.

how about my part 2 in 2nd post ?

the problem now is, the file opens (include works) ...but it doesn't matter where I put the php include on the page, it just starts displaying near the top of the page, and outside of the boundaries I specify to to be cutoff to.

basically i'm opening this file (php include) into a small blog section, and I need it to open just there. (not all over the page)

it initially displayed in the proper area using Javascript

var iframesrc="/news/mysourcefile.htm"  


but I need php include to take it's place. php seems to have a mind of it's own...takes over the whole top part of page.
12:56 am on Feb 13, 2014 (gmt 0)

WebmasterWorld Senior Member penders is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month



...but it doesn't matter where I put the php include on the page, it just starts displaying near the top of the page


Well, that is a bit tricky to debug without seeing the rest of your page, because the contents of the include are included wherever you have the include statement! (If that's not an overuse of the word "include" I don't know what is! ;)

Does the resulting HTML give any clues as to what's going wrong?
 

Featured Threads

My Threads

Hot Threads This Week

Hot Threads This Month