PHP script not workin on dream host servers.. HELP


#1

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 "

Apple stock tracker

Most recent trade: \$$contents[1]

Today's Change: $contents[4]

(Prices delayed up to 20 minutes.)

"; ?>

Any help is appreciated.


#2

I believe fopen is disabled.(?)

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


#3

Yup yup.


#4

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.


#5

In other words, use [url=http://wiki.dreamhost.com/index.php/CURL]these steps in the 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.


#6

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


Simon Jessey
Keystone Websites | si-blog


#7

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