SitePoint Sponsor

User Tag List

Results 1 to 24 of 24
  1. #1
    SitePoint Wizard
    Join Date
    Jun 2005
    Posts
    1,438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP To Insert text from another domain

    Hi all,

    From another thread where I thankfully received some excellent help from some of the other members :

    http://www.sitepoint.com/forums/show...16#post3061116

    or :

    http://tinyurl.com/fuqyf

    I just need a bit more help if possible.

    I think I've gone wrong somewhere, it seems that the rates will only update, if I upload currency.txt ? ;-(

    It's now important that one domain gets it's info from another one, so that :

    As an example, in www.130605.com/currency/index.php the currency is displayed ;

    and that page gets its calculations from www.010805.com/currency/currency.txt

    which gets its calculations from www.010805.com/currency/get_rates.php


    Have I got it correct that the cron job :

    php -q /home/practice/www/currency/get_rates.php > /dev/null

    needs to be on the www.010805.com domain ? (which I would prefer really)


    Also, in the context of the above text and excellent help from the others here, could anyone please fill in/confirm what the chmod's for the bits below should be please ?

    currency.txt - 666 ? The folder that contains currency.txt - ?

    get_rates.php - ? The folder that contains get_rates.php - ?

    index.php - ? The folder that contains index.php - ?

    Any help really appreciated.

    All the best.

    Dez.
    Last edited by Dez; Sep 25, 2006 at 06:46.

  2. #2
    SitePoint Zealot
    Join Date
    Sep 2006
    Posts
    188
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So basically, you want one page to include the contents of www.456-bb.com/currency/currency.txt.

    <?php include('www.456-bb.com/currency/currency.txt'); ?>

    Should work.

    Hope this helps,
    -
    ChrisGilmore
    ChrisGilmore

  3. #3
    SitePoint Wizard
    Join Date
    Jun 2005
    Posts
    1,438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Many thanks Chris - it's appreciated.

    PHP Daemon and a couple of others kindly helped with the code, but since trying to do it, so that one domain gets it from the other, it seems to have gone wrong.

    At the moment, in the index page where the calculations are made, this code is at the top of the page :

    <?php
    $rates=file("http://www.010805.com/currency/currency.txt");
    $dollar_rate=$rates[0];
    $pound_rate=$rates[1];
    ?>

    Which would, essentaiilly be doing the same thing as you suggest - getting the contents of the file - but it just doesn't work, until I physically upload the currency.txt file ? ? ;-(

    If anyone needs any extra info to help on this please let me know.

    Dez.

  4. #4
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    It seems you got it all right. The only permissions you gotta change is for currency.txt, to 666. Leave other files and directories as they are.
    Saul

  5. #5
    SitePoint Wizard
    Join Date
    Jun 2005
    Posts
    1,438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi, I was kinda hoping you were going to appear here

    I did manually upload currency.txt earlier today, so the rates may appear to be correct now for that reason - but have just changed that file to 666 like you suggested and will look again tomorrow.

    There's just a couple of things that I'm really unsure of. Bearing all the following in mind, could you answer the parts asterisked at all please ?

    It's now important that one domain gets it's info from another one, so that :

    As an example, in www.130605.com/currency/index.php the currency is displayed ;

    and that page gets its calculations from www.010805.com/currency/currency.txt

    which gets its calculations from www.010805.com/get_rates.php


    * * Have I got it correct that the cron job :

    php -q /home/mine/www/currency/get_rates.php > /dev/null

    needs to be on the www.010805.com domain ? (which I would prefer really)


    * * Also, in the context of the above text could anyone please fill in/confirm what the chmod's for the bits below should be please ?

    currency.txt - 666 The folder that contains currency.txt - ?

    get_rates.php - ? The folder that contains get_rates.php - ?

    index.php - ? The folder that contains index.php - ?

    Any help really appreciated.

    All the best.

    Dez.

  6. #6
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    The cron job, you can enter a full path to php, I'm not sure if it can find it now.

    Yes, get_rates.php should be ran on 010805.com.

    You should only care about the permissions of currency.txt (666), leave the others default (755, if you didn't change them before, leave them what they are).
    Saul

  7. #7
    SitePoint Wizard
    Join Date
    Jun 2005
    Posts
    1,438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Many thanks for the info php_daemon - I'm learning every day with this php stuff

    The help is much appreciated.

    Hopefully, tomorrow will see an automatic change on the page

    Dez.

  8. #8
    SitePoint Wizard
    Join Date
    Jun 2005
    Posts
    1,438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi php_Daemon - Looked on the page a few moments ago and it had 1 Pound = 1.484 Euros - I then uploaded currency.txt and it changed to 1.469

    Any ideas where it's going wrong at all please.

    Any help very gratefully received.

    Dez.

  9. #9
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Probably cron job is not doing it's job. Check paths again, check if you've set the right period to run it.
    Saul

  10. #10
    SitePoint Wizard
    Join Date
    Jun 2005
    Posts
    1,438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Many thanks for sticking with this one php_Daemon - it's appreciated.

    I tried putting in just the complete file path like you suggested, which would be :

    http://www.010805.com/currency/get_rates.php

    But, then get the error messages in my emails like this :

    /bin/sh: line 1: http://www.010805.com/currency/get_rates.php: No such file or directory

    The file obviously does exist !

    Any help much appreciated.

    Dez.

  11. #11
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Oh, you have misunderstood me. I meant a full path to php compiler, so it looked like:
    /usr/bin/php -q /home/mine/www/currency/get_rates.php > /dev/null

    I don't know if it's /usr/bin/php on your server, you should check what it is.
    Saul

  12. #12
    SitePoint Wizard
    Join Date
    Jun 2005
    Posts
    1,438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for that - just updated the cronjob. Won't know until tomorrow, if it works or not. Will let you know.

    One thing, and I don't know if it's related or not, but the first result doesn't round up or down to 3 figures ?

    All the best.

    Dez.
    Last edited by Dez; Sep 25, 2006 at 09:44.

  13. #13
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Set a cron job to every 10 minutes or so to see if it works sooner than tomorrow.

    What first result?
    Saul

  14. #14
    SitePoint Wizard
    Join Date
    Jun 2005
    Posts
    1,438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yep, I'll do that.

    The first conversion rate ends with 1.49 - but I thought we organised it so that there were 3 digits after the dot ?

    www.130605.com/currency/index.php

    The helps appreciated.

    Dez.

  15. #15
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Check that again, it maybe that it's set to 2.
    Saul

  16. #16
    SitePoint Wizard
    Join Date
    Jun 2005
    Posts
    1,438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I haven't changed anything from when you last did it for me - 'onest guv ;-)

    This is the the code for it :

    1 British Pound &nbsp; = <?php echo round(1/$pound_rate, 3) ?> Euros

    Dez.

  17. #17
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Ah, it doesn't show trailing zeros.
    Saul

  18. #18
    SitePoint Wizard
    Join Date
    Jun 2005
    Posts
    1,438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ah, how do you get it to always show 3 digits after the full stop please ?

    Dez.

  19. #19
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    <?php echo number_format(round(1/$pound_rate3),3?>
    Saul

  20. #20
    SitePoint Wizard
    Join Date
    Jun 2005
    Posts
    1,438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Many thanks for that, it works perfectly.

    ok, I've set the cron to :
    /usr/bin/php -q /home/practice/www/currency/get_rates.php > /dev/null like you kindly suggested, and I've had no error messages, but, the page hasn't updated either ;-(

    What would you like me to do ? Shall I update manually today, ot try something else ?

    All the best.

    Dez.

  21. #21
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Is it really /usr/bin/php on your server? The path can be totally different, you should make sure it is the right path.
    Saul

  22. #22
    SitePoint Wizard
    Join Date
    Jun 2005
    Posts
    1,438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No problem, I'll check with the web hosts.

    Be back as soon as I get an answer.

    Thank you for your time on this.

    Dez.

  23. #23
    SitePoint Wizard
    Join Date
    Jun 2005
    Posts
    1,438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thumbs up

    Hi Php_Daemon,

    Problem all solved - you were right - the path was slightly incorrect.

    I genuinely thank you for all of your time and patience - it's been very much appreciated.

    All the best.

    Dez.

  24. #24
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    You're welcome
    Saul


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •