SitePoint Sponsor |
|
User Tag List
Results 1 to 24 of 24
-
Sep 23, 2006, 01:10 #1
- Join Date
- Jun 2005
- Posts
- 1,441
- 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.
-
Sep 23, 2006, 04:11 #2
- 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,
-
ChrisGilmoreChrisGilmore
-
Sep 23, 2006, 04:27 #3
- Join Date
- Jun 2005
- Posts
- 1,441
- 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.
-
Sep 23, 2006, 04:49 #4
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
-
Sep 23, 2006, 08:09 #5
- Join Date
- Jun 2005
- Posts
- 1,441
- 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.
-
Sep 23, 2006, 09:17 #6
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
-
Sep 23, 2006, 10:07 #7
- Join Date
- Jun 2005
- Posts
- 1,441
- 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.
-
Sep 24, 2006, 01:16 #8
- Join Date
- Jun 2005
- Posts
- 1,441
- 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.
-
Sep 24, 2006, 01:18 #9
Probably cron job is not doing it's job. Check paths again, check if you've set the right period to run it.
Saul
-
Sep 25, 2006, 07:20 #10
- Join Date
- Jun 2005
- Posts
- 1,441
- 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.
-
Sep 25, 2006, 07:28 #11
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
-
Sep 25, 2006, 09:11 #12
- Join Date
- Jun 2005
- Posts
- 1,441
- 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.
-
Sep 25, 2006, 10:29 #13
Set a cron job to every 10 minutes or so to see if it works sooner than tomorrow.
What first result?Saul
-
Sep 25, 2006, 12:26 #14
- Join Date
- Jun 2005
- Posts
- 1,441
- 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.
-
Sep 25, 2006, 12:29 #15
Check that again, it maybe that it's set to 2.
Saul
-
Sep 25, 2006, 12:32 #16
- Join Date
- Jun 2005
- Posts
- 1,441
- 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 = <?php echo round(1/$pound_rate, 3) ?> Euros
Dez.
-
Sep 25, 2006, 12:36 #17
Ah, it doesn't show trailing zeros.
Saul
-
Sep 25, 2006, 12:39 #18
- Join Date
- Jun 2005
- Posts
- 1,441
- 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.
-
Sep 25, 2006, 12:47 #19PHP Code:
<?php echo number_format(round(1/$pound_rate, 3),3) ?>
Saul
-
Sep 26, 2006, 00:44 #20
- Join Date
- Jun 2005
- Posts
- 1,441
- 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.
-
Sep 26, 2006, 01:43 #21
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
-
Sep 26, 2006, 07:58 #22
- Join Date
- Jun 2005
- Posts
- 1,441
- 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.
-
Sep 26, 2006, 08:57 #23
- Join Date
- Jun 2005
- Posts
- 1,441
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
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.
-
Sep 26, 2006, 09:27 #24
Bookmarks