rukamir Posted April 25, 2014 Share Posted April 25, 2014 I am working on OpenShift and my PHP files in my sub directories are not working when pushed to the server. They work through localhost when using XAMPP so I dont know what is going wrong. Any help would be great. I have a link from my main index.php that links to the one in the subdir but when hosted it just pulls up a blank page. I am not sure if this as something to do with PHP permissions or what. /index.php /racedata/index.php Quote Link to comment https://forums.phpfreaks.com/topic/288015-php-not-working-in-subdirectories-on-openshift/ Share on other sites More sharing options...
Ch0cu3r Posted April 25, 2014 Share Posted April 25, 2014 No, idea. Usually a blank page means php has encountered an unrecoverable error. Either check your servers error log or add the following two lines at the top of your script to force php to display errors ini_set('display_errors', 1); error_reporting(E_ALL); Post the error messages in in full and the corresponding code. Quote Link to comment https://forums.phpfreaks.com/topic/288015-php-not-working-in-subdirectories-on-openshift/#findComment-1477273 Share on other sites More sharing options...
rukamir Posted April 25, 2014 Author Share Posted April 25, 2014 (edited) No, idea. Usually a blank page means php has encountered an unrecoverable error. Either check your servers error log or add the following two lines at the top of your script to force php to display errors ini_set('display_errors', 1); error_reporting(E_ALL); Post the error messages in in full and the corresponding code. The error is Warning: include(/resources/layout.php): failed to open stream: No such file or directory in /var/lib/openshift/534f43c45973ca6597000154/app-root/runtime/repo/racedata/index.php on line 13 Warning: include(): Failed opening '/resources/layout.php' for inclusion (include_path='.:/var/lib/openshift/534f43c45973ca6597000154/app-root/runtime/repo/lib:/var/lib/openshift/534f43c45973ca6597000154/app-root/runtime/repo/libs:/var/lib/openshift/534f43c45973ca6597000154/app-root/runtime/repo/libraries:/var/lib/openshift/534f43c45973ca6597000154/app-root/runtime/repo/src:/var/lib/openshift/534f43c45973ca6597000154/app-root/runtime/repo/vendor:/var/lib/openshift/534f43c45973ca6597000154/app-root/runtime/repo/vendors:/var/lib/openshift/534f43c45973ca6597000154/php/phplib/pear/pear/php:/usr/share/pear') in /var/lib/openshift/534f43c45973ca6597000154/app-root/runtime/repo/racedata/index.php on line 13 Its sayins /racedata/resources/layour.php isnt valid... The code is: <?php ini_set('display_errors', 1); error_reporting(E_ALL); // connect to data base //include '/resources/connectdb.php'; // Set page vars $pagetitle = "Front Page!!"; $navbar = "/resources/navbar.php"; $page = "main.php"; $footer = "/resources/footer.php"; // Load complete layout include "/resources/layout.php"; ?> Edited April 25, 2014 by rukamir Quote Link to comment https://forums.phpfreaks.com/topic/288015-php-not-working-in-subdirectories-on-openshift/#findComment-1477274 Share on other sites More sharing options...
Solution Ch0cu3r Posted April 25, 2014 Solution Share Posted April 25, 2014 The problem is most likely to do with the forward slash ( / ) at the start of the file paths. Having the forward slash at the start of file paths does not mean the root of your websites document root, but the root of the servers storage device. This is normal strickly off limits to you, unless you own the server. Try replacing the / with $_SERVER['DOCUMENT_ROOT'] instead eg define('SITE_ROOT', $_SERVER['DOCUMENT_ROOT']); $pagetitle = "Front Page!!"; $navbar = SITE_ROOT . "/resources/navbar.php"; $page = "main.php"; $footer = SITE_ROOT . "/resources/footer.php"; // Load complete layout include SITE_ROOT . '/resources/layout.php/'; Because we now prepend the file paths with the document root path, PHP will now try to load the files from there. Quote Link to comment https://forums.phpfreaks.com/topic/288015-php-not-working-in-subdirectories-on-openshift/#findComment-1477275 Share on other sites More sharing options...
rukamir Posted April 25, 2014 Author Share Posted April 25, 2014 I am still getting the same error. At least now I know PHP is running in that folder that is a plus. Are there any other possible problems you can think of? I am still new to PHP so it is very possible it is something fundamental. Quote Link to comment https://forums.phpfreaks.com/topic/288015-php-not-working-in-subdirectories-on-openshift/#findComment-1477276 Share on other sites More sharing options...
Ch0cu3r Posted April 25, 2014 Share Posted April 25, 2014 It is defiantly a file path issue. So the code you posted is from index.php? which is located at the root of your site? and you're wanting to access files located in the resources directory but PHP is unable to? Quote Link to comment https://forums.phpfreaks.com/topic/288015-php-not-working-in-subdirectories-on-openshift/#findComment-1477278 Share on other sites More sharing options...
rukamir Posted April 25, 2014 Author Share Posted April 25, 2014 You were right about it not liking the '/'. I removed them from the beginning of all and it started working. Thanks for letting me know about DOCUMENT_ROOT and pointing me in the right direction! // Set page vars $pagetitle = "Front Page!!"; $navbar = "resources/navbar.php"; $page = "main.php"; $footer = "resources/footer.php"; // Load complete layout include "resources/layout.php"; Quote Link to comment https://forums.phpfreaks.com/topic/288015-php-not-working-in-subdirectories-on-openshift/#findComment-1477279 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.