Yikes I need help!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
oliverian
Forum Newbie
Posts: 16
Joined: Thu Jan 21, 2010 1:17 pm

Yikes I need help!

Post 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!
User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

Re: Yikes I need help!

Post 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.
Last edited by McInfo on Thu Jun 17, 2010 4:54 pm, edited 1 time in total.
JakeJ
Forum Regular
Posts: 675
Joined: Thu Dec 10, 2009 6:27 pm

Re: Yikes I need help!

Post 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
MiniMonty
Forum Contributor
Posts: 196
Joined: Thu Sep 03, 2009 9:09 am
Location: UK

Re: Yikes I need help!

Post by MiniMonty »

No errors for me either.
Looks OK from my end (Mac, Safari).
User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

Re: Yikes I need help!

Post 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.
Last edited by McInfo on Thu Jun 17, 2010 4:55 pm, edited 1 time in total.
oliverian
Forum Newbie
Posts: 16
Joined: Thu Jan 21, 2010 1:17 pm

Re: Yikes I need help!

Post by oliverian »

I still haven't been able to fix it. Is it because I am using IE browser?
User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

Re: Yikes I need help!

Post 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.
Last edited by McInfo on Thu Jun 17, 2010 4:55 pm, edited 1 time in total.
oliverian
Forum Newbie
Posts: 16
Joined: Thu Jan 21, 2010 1:17 pm

Re: Yikes I need help!

Post 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!
User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

Re: Yikes I need help!

Post 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.
Last edited by McInfo on Thu Jun 17, 2010 4:56 pm, edited 1 time in total.
oliverian
Forum Newbie
Posts: 16
Joined: Thu Jan 21, 2010 1:17 pm

Re: Yikes I need help!

Post 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!
User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

Re: Yikes I need help!

Post 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.
Last edited by McInfo on Thu Jun 17, 2010 4:57 pm, edited 1 time in total.
oliverian
Forum Newbie
Posts: 16
Joined: Thu Jan 21, 2010 1:17 pm

Re: Yikes I need help!

Post by oliverian »

Yes, that did work better as different pages in different directories share that same page. Thanks!
Post Reply