Page 1 of 1

Yikes I need help!

Posted: Thu Jan 21, 2010 1:22 pm
by oliverian
Help! I am getting an error message on my school's site that I can't find the problem to!

Warning: include() [function.include]: URL file-access is disabled in the server configuration in /data/14/1/105/19/1268182/user/1353217/htdocs/public_html/scripts/right-column-long.php on line 4

Warning: include(http://www.oliverianschool.org/scripts/ ... member.php) [function.include]: failed to open stream: no suitable wrapper could be found in /data/14/1/105/19/1268182/user/1353217/htdocs/public_html/scripts/right-column-long.php on line 4

I've loaded old pages, I've looked over the code and can't find the problem to this ugly mess. Any suggestions?

Thanks!

Re: Yikes I need help!

Posted: Thu Jan 21, 2010 1:49 pm
by McInfo
Change

Code: Select all

include('http://www.oliverianschool.org/scripts/dates-to-remember.php');
to

Code: Select all

include('./dates-to-remember.php');
Edit: This post was recovered from search engine cache.

Re: Yikes I need help!

Posted: Thu Jan 21, 2010 1:50 pm
by JakeJ
I didn't get an error when I went to that URL. I got the following output:

DATES TO REMEMBER

Weekend Activities

Winter Vacation
Friday, December 18 -
Monday, January 4

SAT Registration Deadline:
Feb. 4, 2010

ACT Registration Deadline:
March 5, 2010

Re: Yikes I need help!

Posted: Thu Jan 21, 2010 2:59 pm
by MiniMonty
No errors for me either.
Looks OK from my end (Mac, Safari).

Re: Yikes I need help!

Posted: Thu Jan 21, 2010 3:16 pm
by McInfo
oliverian wrote:Warning: include() [function.include]: URL file-access is disabled in the server configuration
For future reference, this error occurred because one or both of allow_url_fopen and allow_url_include are disabled in php.ini.

Edit: This post was recovered from search engine cache.

Re: Yikes I need help!

Posted: Thu Jan 21, 2010 3:23 pm
by oliverian
I still haven't been able to fix it. Is it because I am using IE browser?

Re: Yikes I need help!

Posted: Thu Jan 21, 2010 3:32 pm
by McInfo
Your choice of browser has nothing to do with server errors.

In right-column-long.php, you need to change the include() on line 4 to point to a filesystem path instead of a URL.

Edit: This post was recovered from search engine cache.

Re: Yikes I need help!

Posted: Thu Jan 21, 2010 4:08 pm
by oliverian
I tried changing the code on right-column-long to:


<?php
include "./dates-to-remember.php";
?>

Any ideas on what I am doing? Or at least can you explain it in layman's terms to me?

Thanks!

Re: Yikes I need help!

Posted: Thu Jan 21, 2010 4:45 pm
by McInfo
The "." in "./dates-to-remember.php" references the current directory. (Just for trivia, the parent directory would be "..".)

Assuming the current working directory is scripts, telling right-column-long.php to include "./dates-to-remember.php" should work. And it does if you access the script directly: http://www.oliverianschool.org/scripts/ ... n-long.php.

Apparently, that does not work for the index.php page, which has a different working directory.

You will need to use an absolute path...

Code: Select all

include '/data/.../htdocs/public_html/scripts/dates-to-remember.php'; // (truncated)
...or one relative to index.php.

Code: Select all

include './scripts/dates-to-remember.php';

Code: Select all

include 'scripts/dates-to-remember.php';
Of the two relative paths, the "./" path is preferred because it forces PHP to use the scripts folder in the current directory. With the other path, if there is no scripts folder, PHP will look for a scripts folder in the include_path.

Edit: This post was recovered from search engine cache.

Re: Yikes I need help!

Posted: Fri Jan 22, 2010 9:40 am
by oliverian
Thank you so much McInfo, you got it to work! I used the relative path. Huge stress balloon just deflated in my head. One more question: Do you have any guesses as to why the website was working all along, and all of a sudden the path couldn't be found? I don't believe I have changes those files recently.

Thanks again!

Re: Yikes I need help!

Posted: Fri Jan 22, 2010 11:46 am
by McInfo
I'm not sure why I didn't think of this before... The best solution is to change the include() in right-column-long.php to

Code: Select all

include dirname(__FILE__) . '/dates-to-remember.php';
That is equivalent to PHP 5.3's

Code: Select all

include __DIR__ . '/dates-to-remember.php';
That way, the include() uses an absolute path that is the same whether right-column-long.php is included through index.php or accessed directly through the browser.

__FILE__ and __DIR__ are magic constants.
oliverian wrote:Do you have any guesses as to why the website was working all along, and all of a sudden the path couldn't be found?
Someone probably changed the server configuration to disallow including URLs.

Edit: This post was recovered from search engine cache.

Re: Yikes I need help!

Posted: Sun Jan 24, 2010 10:38 am
by oliverian
Yes, that did work better as different pages in different directories share that same page. Thanks!