Jump to content

Include/require problem


Andy17

Recommended Posts

Hello,

 

 

I have a small and annoying problem. Imagine that I have a main folder on my FTP server which has index.php and I then have a php folder for all of my small scripts and an includes folder for misc files. So, for instance

 

http://www.somedomain.com/index.php

http://www.somedomain.com/php/somescript.php

http://www.somedomain.com/includes/somefile.html

 

Inside somescript.php, I need to use one of the files from the includes folder, like this for example:

 

require('../includes/somefile.html');

 

This is all fine, but the problem is when I include the PHP file on my index.php page. Then I am telling PHP to go one step back to find the includes folder, but the problem is that it only needs to go one step back if it PHP script is not included on some page outside of the php folder. If I run php/somescript.php, there is no problem, but if I include php/somescript.php on my index.php, then there is trouble!

 

I hope you guys understand what I mean. :)

 

Thanks in advance!

 

PS - I would appreciate if the solution is not about moving php/somescript.php or using full URLs in my includes. :)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.