PHP Include wont work!?

Discussion in 'PHP' started by misterdh, Aug 1, 2010.

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

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

    Cookie.php:
    <?php
    if (isset($_COOKIE["background"]))
      $background = $_COOKIE['background'];
    else
      $background = " bgcolor='#FFFFFF'";
    ?>
    PHP:
    It works perfectly if I just enter the code without using a include ...
     
    misterdh, Aug 1, 2010 IP
  2. Bendbull

    Bendbull Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You can't include remote files like that - as long as it can be accessed localy, the following code should work.

    <?php include("cookie.php"); ?>
    PHP:
     
    Bendbull, Aug 1, 2010 IP
  3. MyVodaFone

    MyVodaFone Well-Known Member

    Messages:
    1,048
    Likes Received:
    42
    Best Answers:
    10
    Trophy Points:
    195
    #3
    EDIT: Sorry I was thinking of something else....
     
    Last edited: Aug 1, 2010
    MyVodaFone, Aug 1, 2010 IP
  4. HuggyEssex

    HuggyEssex Member

    Messages:
    297
    Likes Received:
    4
    Best Answers:
    2
    Trophy Points:
    45
    #4
    As someone has said you can only include something that is on the same server.
     
    HuggyEssex, Aug 1, 2010 IP
  5. misterdh

    misterdh Peon

    Messages:
    90
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Of cource!

    Thanks alot guys! :cool:
     
    misterdh, Aug 1, 2010 IP
  6. arpit13

    arpit13 Well-Known Member

    Messages:
    294
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    128
    Digital Goods:
    1
    #6
    u can't include whole url. try:
    <?php include("cookie.php"); ?>
     
    arpit13, Aug 2, 2010 IP