tabco2 Posted June 2, 2008 Share Posted June 2, 2008 I've came across a somewhat unique situation that I'd like to be able to do with PHP. The site is powered on WordPress. This will not make a difference, because all of the coding is being done in the template files, which can accept all raw code. Here's what I wanna do: mysite.com/i/ < has a PHP image hosting script installed (Keep in mind, index.php here includes files in other directories within /i/. Ex. mysite.com/i/index.php calls for includes/file.php & includes/file.php calls for files. mysite.com/wp-content/themes/classic/file.php < I want the image script from mysite.com/i/ to be included & functional here I've tried a variety of include methods, path settings, etc. from various forums and of course the php include manual. Help please? Thanks. Quote Link to comment Share on other sites More sharing options...
tabco2 Posted June 2, 2008 Author Share Posted June 2, 2008 any ideas? Quote Link to comment Share on other sites More sharing options...
trq Posted June 2, 2008 Share Posted June 2, 2008 So, your saying you have a file... mysite.com/wp-content/themes/classic/file.php And from that file you wish to include a file contained within.... mysite.com/i/ ? <?php include $_SERVER['DOCUMENT_ROOT'] . '/i/filename.php'; ?> Quote Link to comment Share on other sites More sharing options...
tabco2 Posted June 2, 2008 Author Share Posted June 2, 2008 So, your saying you have a file... mysite.com/wp-content/themes/classic/file.php And from that file you wish to include a file contained within.... mysite.com/i/ ? <?php include $_SERVER['DOCUMENT_ROOT'] . '/i/filename.php'; ?> Here is the real url: http://classicia.com/image-hosting-sharing/ Thank you for the reply. I tried the code & i get this error: Commons.inc.php is located: http://mysite.com/i/includes/commons.inc.php Warning: main(includes/configs.inc.php) [function.main]: failed to open stream: No such file or directory in /nfs/c02/h05/mnt/24150/domains/classicia.com/html/i/includes/commons.inc.php on line 36 Fatal error: main() [function.require]: Failed opening required 'includes/configs.inc.php' (include_path='.:/usr/local/php-4.4.8-1/share/pear') in /nfs/c02/h05/mnt/24150/domains/classicia.com/html/i/includes/commons.inc.php on line 36 Quote Link to comment Share on other sites More sharing options...
chronister Posted June 2, 2008 Share Posted June 2, 2008 By using $_SERVER['DOCUMENT_ROOT'] your are setting the path from the root of your site. You would use <?php include($_SERVER['DOCUMENT_ROOT'].'/i/includes/commons.inc.php'); ?> This will call it from any page whatsoever. I have found any time your using an include, you should call it using this type of path to avoid the errors. *edit* I just looked at the path in the error, you may need to use /html/i/includes/commons.inc.php. To determine for sure, just echo $_SERVER['DOCUMENT_ROOT']; and see what path you get, then append the path you need to it. Nate Quote Link to comment Share on other sites More sharing options...
tabco2 Posted June 2, 2008 Author Share Posted June 2, 2008 By using $_SERVER['DOCUMENT_ROOT'] your are setting the path from the root of your site. You would use <?php include($_SERVER['DOCUMENT_ROOT'].'/i/includes/commons.inc.php'); ?> This will call it from any page whatsoever. I have found any time your using an include, you should call it using this type of path to avoid the errors. *edit* I just looked at the path in the error, you may need to use /html/i/includes/commons.inc.php. To determine for sure, just echo $_SERVER['DOCUMENT_ROOT']; and see what path you get, then append the path you need to it. Nate http://classicia.com/image-hosting-sharing/ Nate. It ended up that the path needed to be the file directly, for whatever reason. So it's just "commons.inc.php" However, here is the error that followed. Fatal error: Cannot redeclare clean_url() (previously declared in /nfs/c02/h05/mnt/24150/domains/classicia.com/html/wp-includes/formatting.php:1142) in /nfs/c02/h05/mnt/24150/domains/classicia.com/html/i/includes/functions_base.inc.php on line 50 What does this mean? - Or is this digging too far, and there is another solution? Thanks for the help. Quote Link to comment Share on other sites More sharing options...
trq Posted June 2, 2008 Share Posted June 2, 2008 It meens exactly what it says. clean_url() has somehow been defined more than once. Its likely you need to use include_once instead of simply include. Quote Link to comment Share on other sites More sharing options...
tabco2 Posted June 3, 2008 Author Share Posted June 3, 2008 I took care of that, and now it brings me to this error. I know this is generated by the image host script. I looked around in the settings and can't seem to figure out what the path settings should be for it. I tried a variety of paths and nothing seems to work. The tpl_uploader.php is in the exact location of the error though, so it has to be thinking its in a different root directory The template file 'templates/default/tpl_uploader.php' does not exist. Quote Link to comment Share on other sites More sharing options...
tabco2 Posted June 3, 2008 Author Share Posted June 3, 2008 UPDATE: I rigged a little way to get the template to display, and it works: See here: http://classicia.com/image-hosting-sharing/ The next problem, which may end up being the biggest problem, when you click on a link in the uploader it just goes straight to the /i/ directory, leaving out everything else. This sucks. Quote Link to comment Share on other sites More sharing options...
chronister Posted June 3, 2008 Share Posted June 3, 2008 Well, you can fight with paths and such or you can learn to use $_SERVER['DOCUMENT_ROOT'] properly and avoid all path errors. I fought with include paths numerous times before discovering this little gem. If you include a file as include('your_file.php') on a page in /some/directory and then try to call it the same way in a file located in /some/other/directory it will return an error. use $_SERVER['DOCUMENT_ROOT'] and it will not matter where the file calling the include lives because server doc_root is kinda like html's /start/at/root syntax. Your link that you provided gives a 404 error. We can only speculate as to why your pages are ending up at the /i/ dir without seeing any code. Nate Quote Link to comment Share on other sites More sharing options...
tabco2 Posted June 3, 2008 Author Share Posted June 3, 2008 Nate, Thank you for the help. I did learn how to use the Document Root function, and it works well. However, after I fix all the directories to function properly I end up with other errors. I'm working within wordpress, so it gives it a little more difficulty. I really want this to play out smooth though, its important to me. http://classicia.com/images/ < current url & error I'm getting on a 16 hour flight in a few minutes so if my reply is slow, you'll know why. But i'd like to get this sorted out. Thank you again. Quote Link to comment Share on other sites More sharing options...
chronister Posted June 3, 2008 Share Posted June 3, 2008 The errors are because of your paths. try <?php include($_SERVER['DOCUMENT_ROOT'].'/html/i/includes/commons.inc.php'); ?> if that don't work then try <?php include($_SERVER['DOCUMENT_ROOT'].'/i/includes/commons.inc.php'); ?> If neither of those work, then do this and post the results.... <?php echo $_SERVER['DOCUMENT_ROOT']; ?> Quote Link to comment Share on other sites More sharing options...
tabco2 Posted June 4, 2008 Author Share Posted June 4, 2008 At the top is the results to the doc root echo: http://classicia.com/images/ Sorry for the delays. Quote Link to comment Share on other sites More sharing options...
tabco2 Posted June 4, 2008 Author Share Posted June 4, 2008 The errors are because of your paths. try <?php include($_SERVER['DOCUMENT_ROOT'].'/html/i/includes/commons.inc.php'); ?> if that don't work then try <?php include($_SERVER['DOCUMENT_ROOT'].'/i/includes/commons.inc.php'); ?> If neither of those work, then do this and post the results.... <?php echo $_SERVER['DOCUMENT_ROOT']; ?> Ok, I went through all the errors & fixed all the paths it was wanting. And it's brought me to one other dilemma. http://classicia.com/images/ When you click the links on the uploader script, it goes directly to the specified page directly, leaving the wordpress page in which the script is included into... Any ideas on how to keep it within that page? That might require one that's a wordpress experienced person... Let me know if you have any ideas there. Thanks for the help, and I'm trying to do everything possible to figure it out in between your replies. Quote Link to comment Share on other sites More sharing options...
tabco2 Posted June 4, 2008 Author Share Posted June 4, 2008 Finally. It's not fixed, but I've confirmed that it is a wordpress issue. Thanks a MILLION for the help, especially with the directory specific issues. I should be able to figure out everything from here. Thanks again! 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.