PHP Include wont work!?

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
dominod
Forum Commoner
Posts: 75
Joined: Wed Jun 30, 2010 7:18 am

PHP Include wont work!?

Post by dominod »

For some reason this wont work.. Index is jsut returned blank ... Hmm

Index.php :

Code: Select all

<?php
include("http://www.website.com/cookie.php");
?>
Cookie.php:

Code: Select all

<?php
if (isset($_COOKIE["background"]))
  $background = $_COOKIE['background'];
else
  $background = " bgcolor='#FFFFFF'";
?>
It works perfectly if I just enter the code without using a include ...
User avatar
PHPHorizons
Forum Contributor
Posts: 175
Joined: Mon Sep 14, 2009 11:38 pm

Re: PHP Include wont work!?

Post by PHPHorizons »

Check the value of the php ini setting allow_url_fopen
http://www.php.net/manual/en/filesystem ... -url-fopen
http://us2.php.net/manual/en/function.include.php wrote:If "URL fopen wrappers" are enabled in PHP (which they are in the default configuration), you can specify the file to be included using a URL (via HTTP or other supported wrapper - see List of Supported Protocols/Wrappers for a list of protocols) instead of a local pathname.
Cheers
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Re: PHP Include wont work!?

Post by superdezign »

What ~PHPHorizons is suggesting is that, if these files are on your local server and not elsewhere, to use the local path and not the public URL.
dominod
Forum Commoner
Posts: 75
Joined: Wed Jun 30, 2010 7:18 am

Re: PHP Include wont work!?

Post by dominod »

Of cource!

Thanks alot :drunk:
Post Reply