Sign in to follow this  
Followers 0
enlightenmental

PHP fopen, fread HELP! - fix my script!

6 posts in this topic

#1 ·  Posted (edited)

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 ("&nbsp;&nbsp;&nbsp;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>
Edited by enlightenmental

Share this post


Link to post
Share on other sites



This is a AutoIt Forum not a PHP forum or you are trying to translate it into AutoIt code?

If so look at FileOpen, FileRead, StringReplace and some related functions in the helpfile.

Share this post


Link to post
Share on other sites

This is a AutoIt Forum not a PHP forum or you are trying to translate it into AutoIt code?

If so look at FileOpen, FileRead, StringReplace and some related functions in the helpfile.

oops.... this is the best forum I found when searching "forum on php"

not sure what autoit even is.... would be nice if someone could still assist me

(i'll start looking for another forum)

thanks

Share this post


Link to post
Share on other sites

CODE
<?php

$tickersymbol = $_POST['tickersymbol'];

if (!isset($tickersymbol))

{

echo ("&nbsp;&nbsp;&nbsp;Welcome to Stock Port. Here you can view individual stocks by entering the proper Ticker Symbol into the proceeding form.<p>");

?>

<?php

}

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><?php echo ("$read[0]"); ?></TD>

</TR>

<TR>

<TD width=150><b>Last Trade</b>:</TD>

<TD><?php echo ("$read[1]"); ?></TD>

</TR>

<TR>

<TD width=150><b>Last Trade At</b>:</TD>

<TD><?php echo ("$read[2] $read[3]"); ?></TD>

</TR>

<TR>

<TD width=150><b>Change</b>:</TD>

<TD><?php echo ("$read[4]"); ?></TD>

</TR>

<TR>

<TD width=150><b>Opened At</b>:</TD>

<TD><?php echo ("$read[5]"); ?></TD>

</TR>

<TR>

<TD width=150><b>Day Range</b>:</TD>

<TD><?php echo ("$read[6] - $read[7]"); ?></TD>

</TR>

<TR>

<TD width=150><b>Volume</b>:</TD>

<TD><?php echo ("$read[8]"); ?></TD>

</TABLE>

<p>

<img src="http://ichart.yahoo.com/t?s=<?php echo ("$read[0]"); ?>">

</div>

<?php

}

}

?>

<p>

<div align="center">

<FORM ACTION="<?php echo "#" ?>" 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>

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0