this is a simple php script that allows the user to view stock quote tickers by simply entering the ticker into the form
Ive seen this script functioning on several websites
It doesnt work on mine!!
- godaddy hosting
- PHP 5
php.ini file with:
register_globals = true
allow_url_fopen = true
Please help
script
<?
if (!isset($tickersymbol))
{
echo (" Welcome to Stock Port. Here you can view individual stocks by entering the proper Ticker Symbol into the proceeding form.<p>");
?>
<?
}
else if (isset($tickersymbol))
{
$open = fopen("http://quote.yahoo.com/d/quotes.csv?s=$tickersymbol&f=sl1d1t1c1ohgv&e=.csv", "r");
$read = fread($open, 2000);
fclose($open);
$read = str_replace("\"", "", $read);
$read = explode(",", $read);
if ($read[1] == 0)
{
echo ("The symbol you provided (<b>\"$_POST[tickersymbol]\"</b>) doesn't appear to be registered<BR></FONT><BR>");
}
else
{
?>
<div align="center">
<!-- YOU CAN CHANGE THE TABLE BELOW TO MATCH YOUR WEB SITE -->
<TABLE BORDER=1 BORDERCOLOR="#006699" CELLSPACING=0 CELLPADDING=0 WIDTH=500>
<TR>
<TD width=150><b>Ticker Symbol</b>:</TD>
<TD><? echo ("$read[0]"); ?></TD>
</TR>
<TR>
<TD width=150><b>Last Trade</b>:</TD>
<TD><? echo ("$read[1]"); ?></TD>
</TR>
<TR>
<TD width=150><b>Last Trade At</b>:</TD>
<TD><? echo ("$read[2] $read[3]"); ?></TD>
</TR>
<TR>
<TD width=150><b>Change</b>:</TD>
<TD><? echo ("$read[4]"); ?></TD>
</TR>
<TR>
<TD width=150><b>Opened At</b>:</TD>
<TD><? echo ("$read[5]"); ?></TD>
</TR>
<TR>
<TD width=150><b>Day Range</b>:</TD>
<TD><? echo ("$read[6] - $read[7]"); ?></TD>
</TR>
<TR>
<TD width=150><b>Volume</b>:</TD>
<TD><? echo ("$read[8]"); ?></TD>
</TABLE>
<p>
<img src="http://ichart.yahoo.com/t?s=<? echo ("$read[0]"); ?>">
</div>
<?
}
}
?>
<p>
<div align="center">
<FORM ACTION="<? echo ("$PHP_SELF"); ?>" METHOD="POST">
<table border=0 cols=2 width=200>
<tr>
<td width=100>
Ticker Symbol:
</td>
<td width=100>
<input type=text name="tickersymbol">
</td>
</tr>
<tr align="center">
<td colspan=2>
<input type=submit value="Check Stock">
</td>
</tr>
</table>
</FORM>
</div>