PDA

View Full Version : Php Include


robcarr2
05-01-2004, 12:56 PM
I am trying to use a php include code so that my phpbb board will show on my forum.php page but it comes up with the following error

Warning: Failed opening 'http://www.feedonfrenzy1.co.uk/mammal/forum/phpBB2/index.php' for inclusion (include_path='.:/usr/share/pear:/usr/share/php/PEAR') in /customers/feedonfrenzy1.co.uk/feedonfrenzy1.co.uk/httpd.www/mammal/forum.php on line 43

Here is the php i used, if anyone has any ideas please write back.

<?php
include 'http://www.feedonfrenzy1.co.uk/mammal/forum/phpBB2/index.php';
?>

agent002
05-01-2004, 01:04 PM
hi,
in future, please ask all PHP questions in the PHP subforum (http://www.htmlforums.com/forumdisplay.php?s=&forumid=44). :)
The problem is that you should use a server path, not an URL. A server path is the path on the server, the path to your webspace root might be something similiar to /usr/home/your_username. Try using the path to phpBB, relative to your webspace root, that could maybe be ./forum/phpBB2/index.php if your root URL is http://www.feedonfrenzy1.co.uk/mammal/. :)

darksidepuffin
05-01-2004, 01:09 PM
Atchually...the problem is php can't find the file.You can use either paths or urls with include(); and require();.Double check CaSe and spelling of the url.

agent002
05-01-2004, 01:27 PM
Originally posted by willamoose
You can use either paths or urls with include(); and require();.
Sorry, didn't know that. It sounds quite strange to me actually, that you can use URLs.

Josh
05-01-2004, 01:34 PM
Yes, which can actually be a problem if you're using a query string at the end of the URL.

For example, if you have http://www.site.com/index.php?page=games.php and you have no way of checking that the included part is from your site or not, you could do http://www.site.com/index.php?page=http://www.google.com
which is of course, not a good thing.

darksidepuffin
05-01-2004, 02:14 PM
Josh makes a good point...never use the filename from the query string directly without proper validation.

Josh
05-01-2004, 03:03 PM
Hehe, I've actually found a site that allows that, and have been able to change the end of the URL to access a site at school that would normally be blocked.

darksidepuffin
05-01-2004, 03:58 PM
there are sites that purposely do it..but they know how to properly process the input.

fevertje
05-01-2004, 04:29 PM
You can only use URL in include if the option "URL fopen wrappers" in php.ini is set to allow this.

php versions prior to 4.3.0 will actually never allow url to be used in include.

Source: http://www.php.net/manual/en/function.include.php
and http://www.php.net/manual/en/ref.filesystem.php#ini.allow-url-fopen

Maybe a possible answer?

darksidepuffin
05-01-2004, 05:24 PM
good point fev'...altho isnt allow-url-fopen enabled by default?I've never known a host to disable it.

fevertje
05-01-2004, 05:57 PM
You've got a good point there yourself will :)

darksidepuffin
05-01-2004, 06:12 PM
Originally posted by fevertje
You've got a good point there yourself will :)

:)...mind if I ask your name there Fev'?

althalus
05-01-2004, 06:14 PM
i think my host disabled it (or i got it all wrong.. either way)..

check (http://mng.zer0host.com/index.php?id=http://www.google.com)? or did i misunderstand? :confused:

Josh
05-01-2004, 06:16 PM
Well you're links don't have the extension at the end, just the name. Which probably means you're using cases, so most likely you have something in your code not allowing off site files to be included.

althalus
05-01-2004, 06:32 PM
hmm well yes, .php is sort of predefined. guess i'm sort of safe then :)

sort of.. ;)

fevertje
05-01-2004, 06:36 PM
Originally posted by willamoose
:)...mind if I ask your name there Fev'?
My real name? This is the internet you know. The only place where I do not have to be myself ;) Seriously, it's just stefaan...

To get back on topic hehe, just run phpinfo() somewhere on your hosting server if you haven't got access to php.ini there, the setting is noted inthere.

darksidepuffin
05-01-2004, 09:03 PM
alrighty Stefaan (:D) has another good point....altho...better still...why not just make a phpinfo.php file and link us to it?that way we can point out any settings that may cause your issues :)

scoutt
05-02-2004, 10:35 AM
uhh don't use include, just load the site in a iframe instead.