jodiellewellyn Posted April 14, 2007 Share Posted April 14, 2007 Hey all, I'm running a script at the moment that requires the full path to my directory. How do I figure this out? Cheers, Jodie Quote Link to comment Share on other sites More sharing options...
jakebur01 Posted April 14, 2007 Share Posted April 14, 2007 Do you mean like $DOCUMENT_ROOT = $_SERVER['DOCUMENT_ROOT']; Quote Link to comment Share on other sites More sharing options...
jodiellewellyn Posted April 14, 2007 Author Share Posted April 14, 2007 Perhaps... But when I put that into a .php document and try to view it... it just comes up blank ? Quote Link to comment Share on other sites More sharing options...
jakebur01 Posted April 14, 2007 Share Posted April 14, 2007 Sometimes if you have the code as <? rather that <?php the page will come up blank as well. Quote Link to comment Share on other sites More sharing options...
jodiellewellyn Posted April 14, 2007 Author Share Posted April 14, 2007 Yeah, I have it as <? $DOCUMENT_ROOT = $_SERVER['DOCUMENT_ROOT']; ?> But... it still comes up with a completely blank page. Quote Link to comment Share on other sites More sharing options...
jakebur01 Posted April 14, 2007 Share Posted April 14, 2007 Do you have more of the code? Quote Link to comment Share on other sites More sharing options...
jodiellewellyn Posted April 14, 2007 Author Share Posted April 14, 2007 No Quote Link to comment Share on other sites More sharing options...
Voldemort Posted April 14, 2007 Share Posted April 14, 2007 <?php $DOCUMENT_ROOT = $_SERVER['DOCUMENT_ROOT']; echo $DOCUMENT_ROOT; ?> You were forgetting to echo the variable... Quote Link to comment Share on other sites More sharing options...
jodiellewellyn Posted April 14, 2007 Author Share Posted April 14, 2007 It comes up with a / But the thing is, I need a full path to my directory eg. /home/youruser/public_html/directory/cards/regular/ or something. Quote Link to comment Share on other sites More sharing options...
Guest prozente Posted April 14, 2007 Share Posted April 14, 2007 echo getcwd(); Quote Link to comment Share on other sites More sharing options...
jodiellewellyn Posted April 14, 2007 Author Share Posted April 14, 2007 echo getcwd(); It only comes up with the last directory.... not all the stuff prior to it. Quote Link to comment Share on other sites More sharing options...
Guest prozente Posted April 14, 2007 Share Posted April 14, 2007 you're probably under a chroot then Quote Link to comment Share on other sites More sharing options...
jodiellewellyn Posted April 14, 2007 Author Share Posted April 14, 2007 you're probably under a chroot then Can you explain that? Quote Link to comment Share on other sites More sharing options...
Guest prozente Posted April 14, 2007 Share Posted April 14, 2007 http://en.wikipedia.org/wiki/Chroot Quote Link to comment Share on other sites More sharing options...
HeyRay2 Posted April 14, 2007 Share Posted April 14, 2007 All the following $_SERVER variables should contain your "full path": $_SERVER["DOCUMENT_ROOT"] $_SERVER["PHPRC"] Also, you could always just make a file with a syntax error that will spit out an error with the full path to the file. Something like... <?php foreach() ?> ... should generate an error. PHP errors are so useful sometimes... Quote Link to comment Share on other sites More sharing options...
jodiellewellyn Posted April 14, 2007 Author Share Posted April 14, 2007 All the following $_SERVER variables should contain your "full path": $_SERVER["DOCUMENT_ROOT"] $_SERVER["PHPRC"] Also, you could always just make a file with a syntax error that will spit out an error with the full path to the file. Something like... <?php foreach() ?> ... should generate an error. PHP errors are so useful sometimes... Still a blank page... even with the error. Quote Link to comment Share on other sites More sharing options...
HeyRay2 Posted April 14, 2007 Share Posted April 14, 2007 Your web host must have error reporting turned off: Try this: <?php phpinfo(); ?> ... and scroll down the "PHP Variables" section ... Quote Link to comment Share on other sites More sharing options...
jodiellewellyn Posted April 14, 2007 Author Share Posted April 14, 2007 Your web host must have error reporting turned off: Try this: <?php phpinfo(); ?> ... and scroll down the "PHP Variables" section ... The page certainly works... But none of the codes is what I want... Unless I have to put a few together Quote Link to comment Share on other sites More sharing options...
Voldemort Posted April 14, 2007 Share Posted April 14, 2007 <?php foreach($_SERVER as $name => $value){ echo $name . ": " . $value . "<br />"; } ?> Put that in a test page, look for the one you want. Quote Link to comment Share on other sites More sharing options...
jodiellewellyn Posted April 14, 2007 Author Share Posted April 14, 2007 <?php foreach($_SERVER as $name => $value){ echo $name . ": " . $value . "<br />"; } ?> Put that in a test page, look for the one you want. So I came up with this PATH: /usr/bin:/bin I'm just not sure where to get the rest. Quote Link to comment Share on other sites More sharing options...
per1os Posted April 14, 2007 Share Posted April 14, 2007 If you are using the PHP as CGI than you cannot get the Document_root as it points to the php.exe. A minor flaw in having PHP loaded as a CGI Module in Apache. I would check that out as it could be the key. Quote Link to comment Share on other sites More sharing options...
jodiellewellyn Posted April 14, 2007 Author Share Posted April 14, 2007 I'm using PHP through Geocities. Quote Link to comment Share on other sites More sharing options...
Barand Posted April 14, 2007 Share Posted April 14, 2007 try echo realpath('.'); 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.