Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

Not all stock information is showing up please help?

$
0
0
    <html>
    <body>
    <h2>Stock </h2>
    <?php
    
    //$ticker = "goog";
 
    
    if (isset($_GET['get_quote'])) {
    $ticker = $_GET['ticker'];
    }
    
    $open = fopen("http://download.finance.yahoo.com/d/quotes.csv?s=$ticker&f=sl1d1t1c1ohgv&e=.csv", "r");
    
    $quote = fread($open, 1000);
    
    fclose($open);
    
    $quote = str_replace("\"", "", $quote);
    $quote = explode(",", $quote);
    
    $stock_0 = ($quote[0]);
    $stock_1 = ($quote[1]);
    $stock_2 = ($quote[2]);
    $stock_3 = ($quote[3]);
    $sotck_4 = ($quote[4]);
    $stock_5 = ($quote[5]);
    
    
    echo "Company:      <b>$stock_0</b><br>";
    echo "Last trade:   <b>$stock_1</b><br>";
    echo "Date:         <b>$stock_2</b><br>";
    echo "Time:         <b>$stock_3</b><br>";
    echo "High:         <b>$sotck_4</b><br>";
    echo "Low:          <b>$stock_5</b><br>";
    
    ?>
    
    <br><br>
    <form action="stockfetch.php" method="get">
    
    Enter Quote: <input type="text" size="10" maxlength="10" name="ticker"/>
    <input type="submit" value="Enter Quote" name="get_quote" />
    </form>
    </body>
    </html>
 

 



Can you help me resolve the fix the "Undefined offset on line 1-5" i can't seem to figure out how to fix that error?

When i enter in symbol such as goog it retrieves the right stock information from the csv, but when i first load my stock fetcher it has problems?

 

When i type in other symbols it seems to yooh it comes with n/a but google seems to work.


Viewing all articles
Browse latest Browse all 13200

Trending Articles