PHP Stock ticker question

Discussion in 'HTML & Website Design' started by new2u, Mar 25, 2010.

  1. #1
    Adding a php script to a site and cant get it to display the quote.. wonderin if anyone has some insight? Whats happening is it displays like this... When I want the N/A to Show quotes
    MSFT N/A
    Day high N/A
    Day low N/A

    Thanks in advance

    <?php $MSFT=GetQuote("MSFT"); ?>

    <h1>Stock quote</h1>
    <p>
    <table width="90%" border="0" cellpadding="1" cellspacing="0">
    <tr>
    <td width="50%"><a href="http://finance.yahoo.com/q?s=MSFT" target="_blank"><strong>MSFT </strong></a></td>
    <td width="15%" align="right"><a href="http://finance.yahoo.com/q?s=MSFT" target="_blank" class="stockLink">
    <?php print((isset($MSFT['Last_Traded_Price']) && trim(chop($MSFT['Last_Traded_Price']))!="")? $MSFT['Last_Traded_Price']: "N/A"); ?></a></td>
    </tr>

    <tr>
    <td><a href="http://finance.yahoo.com/q?s=MSFT" target="_blank">Day high</a></td>
    <td align="right"><a href="http://finance.yahoo.com/q?s=MSFT" target="_blank">
    <?php print((isset($MSFT['Days_High']) && trim(chop($MSFT['Days_High']))!="")? $MSFT['Days_High']: " N/A"); ?></a></td>
    </tr>

    <tr>
    <td><a href="http://finance.yahoo.com/q?s=MSFT" target="_blank">Day low</a></td>
    <td align="right"><a href="http://finance.yahoo.com/q?s=MSFT" target="_blank">
    <?php print((isset($MSFT['Days_Low']) && trim(chop($MSFT['Days_Low']))!="")? $MSFT['Days_Low']: "N/A"); ?></a></td>
    </tr>
    </table>
    </p>
    </div>
     
    new2u, Mar 25, 2010 IP
  2. canadianguy_001

    canadianguy_001 Peon

    Messages:
    97
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Is GetQuote a function you wrote yourself? or is it a function you downloaded from somewhere. It is clear that it is not reading the quote properly, but it is hard to troubleshoot it without knowing what the function is attempting to do, and where it is fetching the quotes from (presumably RSS or XML).

    Chances are the function is trying to fetch a quote from an XML feed that either no longer exists, or has been restructured since the time of the function being written.
     
    canadianguy_001, Mar 25, 2010 IP
  3. new2u

    new2u Peon

    Messages:
    103
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Sorry forgot to add that.. near the top of my php I have

    function GetQuote($Symbol="MSFT")
    {
    $url="http://download.finance.yahoo.com/d/quotes.csv?s=MSFT&f=sl1d1t1c1ohgv&e=.csv";


    }
     
    Last edited: Mar 25, 2010
    new2u, Mar 25, 2010 IP
  4. new2u

    new2u Peon

    Messages:
    103
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I think the issue may be that they used to label their fields on the csv and they stopped doing that... sound right?
     
    new2u, Mar 25, 2010 IP
  5. new2u

    new2u Peon

    Messages:
    103
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Figured it out.. thanks guys
     
    new2u, Mar 29, 2010 IP