Problem with PHP include

Discussion in 'PHP' started by jonno_81, Dec 30, 2009.

  1. #1
    Hi there,

    I feel like a bit of a chop (colloquial expression for an idiot) because I really should know this...

    I do web development for clients and on certain client sites I want to be able to include a line of text. BUT, I may want to change that line from time to time, so what I want to do is put a file on MY server with the line, and then include this file on THEIR server.

    SO,

    On MY server, a file called clienttext.inc

    <?
    $TextLine = "This must show on the client site";
    ?>


    and on THEIR server:

    <?

    // other stuff

    include("http://www.softsmart.co.za/path/clienttext.inc");
    print $TextLine;

    ?>



    But, it doesn't seem to work.

    Please help

    Thanks,

    John :confused:
     
    jonno_81, Dec 30, 2009 IP
  2. kecoa-ngamuk

    kecoa-ngamuk Peon

    Messages:
    40
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Have you tryin switch to file_get_content ? maybe it disabled on your host?
    <?
    $textinc = file_get_contents("http://www.softsmart.co.za/path/clienttext.inc");
    echo ($textinc);
    ?>
    PHP:
     
    kecoa-ngamuk, Dec 30, 2009 IP
  3. kleinnico

    kleinnico Peon

    Messages:
    40
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    To communicate between different websites you can use different methods.

    If Website A has the line of text and Website B wants to use it. The normal way should be that Website A just echo's the line text. And Website B gets the line text with file_get_contents() - as kecoa-ngamuk did.

    If you have more than just one text line, you should use XML or JSON.

    However the method of loading an external PHP file, then load it as PHP with eval() and then using the variables is not very common nor good.
     
    Last edited: Dec 30, 2009
    kleinnico, Dec 30, 2009 IP
  4. kingsoflegend

    kingsoflegend Well-Known Member

    Messages:
    202
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    108
    #4
    Nice job being condescending (=arrogant and patronizing) by explaining to us what that word means, but the word you're looking for is actually "chump" not "chop".
     
    kingsoflegend, Dec 30, 2009 IP
  5. jonno_81

    jonno_81 Well-Known Member

    Messages:
    81
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    115
    #5
    Umm... No, its chop. That's why I said colloquial (meaning colloquial in my country). Nice try though.

     
    jonno_81, Dec 30, 2009 IP
  6. jonno_81

    jonno_81 Well-Known Member

    Messages:
    81
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    115
    #6
    Thanks for the posts everyone. I got things to work on some servers and not others. As I don't have access (besides FTP), I decided to use CURL to read in the file I was after.

    Thanks...

    John
     
    jonno_81, Dec 30, 2009 IP
  7. astkboy2008

    astkboy2008 Peon

    Messages:
    211
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #7
    you cant include fiile from out server like that
    include("http://www.softsmart.co.za/path/clienttext.inc");
    use curl
     
    astkboy2008, Dec 30, 2009 IP