xubuntu69 Posted August 17, 2014 Share Posted August 17, 2014 Hi , i read many articles and tried many things before asking but i came to a dead end. My problem is very simple (or at least i believe so). In the main directory \httpdocs there is this file we call "header.php" and another file we call "article.php". So the code of the article is very simple: <?php include("header.php"); echo "bla bla bla\n"; ?> So far so good. Let's say that we create a new folder \httpdocs\new_folder and inside there we create a new file that we call "new_file.php". So we would simple like to call the header.php from the parent folder BUT IT TURNS TO BE IMPOSSIBLE ! I have tried: include('../header.php'); (in an article of this website says that this work - well IT DOESN'T ! i have tried many other things but i cannot load the header.php from the previous directory ! I wanna tip the person who will find the solution so you better leave a paypal along with the answer ! Quote Link to comment https://forums.phpfreaks.com/topic/290504-previous-directory-issue/ Share on other sites More sharing options...
thilakan Posted August 17, 2014 Share Posted August 17, 2014 TRY include("httpdocs/new_folder/header.php"); Quote Link to comment https://forums.phpfreaks.com/topic/290504-previous-directory-issue/#findComment-1488062 Share on other sites More sharing options...
mogosselin Posted August 17, 2014 Share Posted August 17, 2014 Hello, I tested it on my machine and it works great. File #1: header.php at the root File #2: index.php in a sub folder. Here's the content of index.php: <?php include('../header.php'); ?> Are you sure you don't get a permission error or a syntax error? Did you check your logs? Are you on Windows or Linux? Alternatively, you could try this code: <?php include($_SERVER['DOCUMENT_ROOT'] . "/header.php"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/290504-previous-directory-issue/#findComment-1488063 Share on other sites More sharing options...
xubuntu69 Posted August 18, 2014 Author Share Posted August 18, 2014 (edited) This is not even loading ! There must be a problem with this symbol -> ' I dont think you can use " and also '. <?php include($_SERVER['DOCUMENT_ROOT'] . "/header.php"); ?> The message below include("httpdocs/new_folder/header.php"); this is totally wrong because header.php is not located in the new folder... If someone does not believe me i can provide user/pass to see himself... All these things and many more are simply NOT WORKING. Edited August 18, 2014 by xubuntu69 Quote Link to comment https://forums.phpfreaks.com/topic/290504-previous-directory-issue/#findComment-1488108 Share on other sites More sharing options...
Ch0cu3r Posted August 18, 2014 Share Posted August 18, 2014 Either of the solution mogosselin posted should be working for you from how you described your problem. There must be a problem with this symbol -> ' I dont think you can use " and also '. What! That is nonsense. An array key can be wrapped in single or double quotes doesn't matter which is used. Do you get any error messages? If you don't then I suggest your turn error reporting on. Either in your php.ini configuration or apply this to the very top of your code (after the opening PHP tag) ini_set('display_errors', 1); error_reporting(E_ALL); Quote Link to comment https://forums.phpfreaks.com/topic/290504-previous-directory-issue/#findComment-1488113 Share on other sites More sharing options...
xubuntu69 Posted August 18, 2014 Author Share Posted August 18, 2014 (edited) ok so.... <?php $magictitle = "Blinds Stealing - Poker Lesson School"; require_once('mainfile.php'); $module_name = basename(dirname(__FILE__)); $index = 1; include('header.php'); include('footer.php'); ?> this file is working , have a look www.pokerhaze.com/az.php But his file ... <?php $magictitle = "Blinds Stealing - Poker Lesson School"; require_once('../mainfile.php'); $module_name = basename(dirname(__FILE__)); $index = 1; include('../header.php'); include('../footer.php'); ?> this file is not working , look here www.pokerhaze.com/blog/az.php i had the "errors display" on .. without any errors... could someone explain what is going on and why the file httpdocs/blog/az.php folder cannot read the files from parent folders? I have tested also other folders and other file names, can't do it. Edited August 18, 2014 by xubuntu69 Quote Link to comment https://forums.phpfreaks.com/topic/290504-previous-directory-issue/#findComment-1488126 Share on other sites More sharing options...
Ch0cu3r Posted August 18, 2014 Share Posted August 18, 2014 (edited) i had the "errors display" on .. without any errors... In the php.ini? If thats the case you should not be getting a blank white screen. Check your servers error logs for the errors too. Your could change your code to this to see where it is failing <?php echo "I am in: " . getcwd(); function require_file($file) { echo "<p>Checkfing if $file exists in ".realpath(dirname($file))." ..."; if(file_exists($file)) { echo "OK, attemping to require it... "; require_once($file); echo "OK"; } else { echo 'FAIL'; } echo '</p>'; } $magictitle = "Blinds Stealing - Poker Lesson School"; require_file('../mainfile.php'); $module_name = basename(dirname(__FILE__)); $index = 1; require_file('../header.php'); require_file('../footer.php'); ?> Edited August 18, 2014 by Ch0cu3r Quote Link to comment https://forums.phpfreaks.com/topic/290504-previous-directory-issue/#findComment-1488131 Share on other sites More sharing options...
nik_jain Posted August 18, 2014 Share Posted August 18, 2014 This link http://www.pokerhaze.com/blog/az.php is throwing a "500 internal server error" What are the permissions on the blog folder ? Try matching them to the httpdocs folder (just a guess) Also try commenting out the includes one by one to see what is causing the internal server error. Quote Link to comment https://forums.phpfreaks.com/topic/290504-previous-directory-issue/#findComment-1488152 Share on other sites More sharing options...
xubuntu69 Posted August 19, 2014 Author Share Posted August 19, 2014 Ch0cu3ri copy pasted your code it is not even loading.... !!! www.pokerhaze.com/blog/az.php If you think i do something wrong i can provide ftp access so you can see for yourself. But i just copy pasted the code, nothing is wrong. Quote Link to comment https://forums.phpfreaks.com/topic/290504-previous-directory-issue/#findComment-1488278 Share on other sites More sharing options...
jazzman1 Posted August 19, 2014 Share Posted August 19, 2014 (edited) Can I see the directories/files structure from this project? Do you see .htaccess files somewhere? PS: You can PM'ed me giving me an ftp access to this server. Edited August 19, 2014 by jazzman1 Quote Link to comment https://forums.phpfreaks.com/topic/290504-previous-directory-issue/#findComment-1488279 Share on other sites More sharing options...
jazzman1 Posted August 19, 2014 Share Posted August 19, 2014 Do you see this structure somewhere on the server - http://pokerhaze.com:8080/index.jsp (webapps/ROOT/) I am not familiar with Tomcat, but I'd try to help you. Quote Link to comment https://forums.phpfreaks.com/topic/290504-previous-directory-issue/#findComment-1488282 Share on other sites More sharing options...
Ch0cu3r Posted August 19, 2014 Share Posted August 19, 2014 Sounds to me an issue with how your server is setup. I'd recommend you to start looking at your servers error logs to identify the cause of the 500 Internal Server Error. Quote Link to comment https://forums.phpfreaks.com/topic/290504-previous-directory-issue/#findComment-1488288 Share on other sites More sharing options...
xubuntu69 Posted August 19, 2014 Author Share Posted August 19, 2014 where are the servers logs ? i dont have access to everything, i pay for domain hosting Quote Link to comment https://forums.phpfreaks.com/topic/290504-previous-directory-issue/#findComment-1488289 Share on other sites More sharing options...
jazzman1 Posted August 19, 2014 Share Posted August 19, 2014 (edited) Check the permissions on the files in this particular directory. Now should work - http://www.pokerhaze.com/blog/az.php The files (header and footer) should be executable also to be able to execute the content. What do you want to accomplish, a new template? Edited August 19, 2014 by jazzman1 Quote Link to comment https://forums.phpfreaks.com/topic/290504-previous-directory-issue/#findComment-1488296 Share on other sites More sharing options...
xubuntu69 Posted August 19, 2014 Author Share Posted August 19, 2014 (edited) I want to accomplish this : there is an addon that i installed www.pokerhaze.com/blog and i want to load this add on with the header and the footer of my website !!!! Thats all !! can we do it ? your new script is not working http://www.pokerhaze.com/blog/az.php it seams so easy and so impossible.... Edited August 19, 2014 by xubuntu69 Quote Link to comment https://forums.phpfreaks.com/topic/290504-previous-directory-issue/#findComment-1488301 Share on other sites More sharing options...
jazzman1 Posted August 19, 2014 Share Posted August 19, 2014 I'm at work now...but this is a content management system that I'm not familiar with...but I could try later to include the header and footer to this. Quote Link to comment https://forums.phpfreaks.com/topic/290504-previous-directory-issue/#findComment-1488305 Share on other sites More sharing options...
xubuntu69 Posted August 19, 2014 Author Share Posted August 19, 2014 (edited) The content management is irrelavent. Just make a new folder, create a new file in there and try to include the header or footer from the previous folder... it will turn out to be impossible. The server setup that someone mentioned above is also irrelavent. There are no restrictions of any kind like httaccess ... The conclussion is this FILES from previous folders cannot be loaded. Edited August 19, 2014 by xubuntu69 Quote Link to comment https://forums.phpfreaks.com/topic/290504-previous-directory-issue/#findComment-1488338 Share on other sites More sharing options...
jazzman1 Posted August 19, 2014 Share Posted August 19, 2014 (edited) No, it is The header and footer files are part of this CMS and they contain a lot of logic. If you create files for instance, _header.php and _footer.php in the same directory when header.php and footer.php are, you will be able to include them to az.php ( I tried ) Try! Edited August 19, 2014 by jazzman1 Quote Link to comment https://forums.phpfreaks.com/topic/290504-previous-directory-issue/#findComment-1488340 Share on other sites More sharing options...
Ch0cu3r Posted August 19, 2014 Share Posted August 19, 2014 @xubuntu69 so this is all false information! Do you really think if this was not possible we'd post code which will never work. Also it would of been beneficial at the start you told use that these files you were trying to include where part of your CMS. Jazzman1 has concluded your CMS is at fault. It is restricting where certain files can and can nott be included from, maybe its for security. You can only blame the creators of the CMS for not being flexible enough. Quote Link to comment https://forums.phpfreaks.com/topic/290504-previous-directory-issue/#findComment-1488341 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.