PHP script not workin on dream host servers.. HELP

PHP script not workin on dream host servers.. HELP

Posted by: dave79
Posted on: 2005-06-01 10:59:00

Ok i am running a phpscript that fetches the info from yahoo.com finance but i cant get it to work http://www.investingpub.com/quotes.php

the code is
<?php
$fd = fopen ("http://quote.yahoo.com/d/quotes.csv?s=AAPL&f=sl1d1t1c1ohgv&e=.csv", "r");
$contents = fread ($fd, 200);
fclose ($fd);

$contents = str_replace (""", "", $contents);
$contents = explode (",", $contents);

echo "<p>Apple stock tracker</p><p>Most recent trade: <b>$$contents[1]</b></p><p>Today's Change: $contents[4]</p><p>(Prices delayed up to 20 minutes.)</p>";
?>

Any help is appreciated.

Re: PHP script not workin on dream host servers.. HELP

Posted by: MaliciousKitty
Posted on: 2005-06-01 11:09:00

I believe fopen is disabled.(?)

Edit:
What wiki says about allow_url_fopen
http://wiki.dreamhost.com/index.php/Allow_url_fopen

Edited by MaliciousKitty on 06/01/05 11:11 AM (server time).

Re: PHP script not workin on dream host servers..

Posted by: Iri
Posted on: 2005-06-01 11:11:00

In reply to:

I believe fopen is disabled.


Yup yup.

Re: PHP script not workin on dream host servers..

Posted by: guice
Posted on: 2005-06-01 11:12:00

fopen isn't disabled. However, allow_url_fopen is, which means you can use fopen(), but you cannot supply a URL of any type for opening.

Re: PHP script not workin on dream host servers..

Posted by: decswxaqz
Posted on: 2005-06-01 11:46:00

In other words, use these steps in the [url=http://wiki.dreamhost.com]wiki.
I recommend changing the
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 1);
line to 5-10 because otherwise, it'll time out after 1 second, which isn't good for accessing other web pages.

Re: PHP script not workin on dream host servers..

Posted by: scjessey
Posted on: 2005-06-01 11:51:00

In reply to:

I recommend changing the

curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 1);

line to 5-10 because otherwise, it'll time out after 1 second, which isn't good for accessing other web pages.


I totally agree. I've changed that script slightly to reflect your suggestion.

Re: PHP script not workin on dream host servers..

Posted by: dave79
Posted on: 2005-06-01 12:13:00

thanks I will try it out tonight. Hopefully it will work. Thanks!!

Tags: php scripthost serversworkinquotesrunningfinancehelphttp