Not As Easy As I Thought

Hi. I have been working on this non stop. I am trying to do a simple task of just reading a file into a variable. Somehow it isnt working. here is my code.

<?php $Symbol='qqq'; $url = "http://finance.yahoo.com/d/quotes.csv?s=$Symbol&f=st5l9c6p4b1a3"; //echo $url; //if(file_get_contents("http://finance.yahoo.com/d/quotes.csv?s=$Symbol&f=st5l9c6p4b1a3")){ if( fopen("$url", "r")){ echo "file works"; }else{ echo "LIFE SUCKS!!"; } $readl= implode(file("http://finance.yahoo.com/d/quotes.csv?s=$Symbol&f=st5l9c6p4b1a3")); echo $readl; for ($i=0;$i<8;$i++) { $read = str_replace(""", "", $readl[$i]); $read = explode(",", $read); $Symbol=$read[0]; $LastPrice=$read[2]; $Change=$read[3]; $ChangePercent=$read[4]; } ?>

<?=$Symbol?><?=$LastPrice?>–<?=$Change?>–<?=$ChangePercent?>

If you could help me out that would be great. THANKS

What happens? That would help us figure out what’s wrong.

One easy answer is that you may not have the fopen() URL wrappers enabled (ie, fopen() and friends are not capable of handling URL file paths, only local ones).

Sponsor our Newsletter | Privacy Policy | Terms of Service