Forum Moderators: coopster

Message Too Old, No Replies

php and static url problem

stock quotes page isn't working

         

daneosporin

4:16 pm on Sep 26, 2005 (gmt 0)

10+ Year Member



I recently began trying to add stock quotes to my site using yahoo's csv feed and did not get very far... The stock quote page worked fine on its own the problem is when I try to make static pages. I have some links on the page to the popular stocks' static urls. When I go to one of these urls the stock quote script no longer works and keep strying to get quotes for the the stock that is in the name of the static url istead of the new stock from the form.

here's the stock quote code:


<p><center>
<?php
$stock = $_GET['stock'];
$fp = fopen ("http://finance.yahoo.com/d/quotes.csv?s=$stock&f=sl1d1t1c1ohgv&e=.csv","r");
$data = fgetcsv ($fp, 1000, ",");
?>
<h1>Stock Quotes</h1>
<table>
<tr><td>symbol</td><td><?php echo $data[0]?></td></tr>
<tr><td>last price</td><td><?php echo $data[1]?></td></tr>
<tr><td>change</td><td><?php echo $data[4]?></td></tr>
<tr><td>open</td><td><?php echo $data[5]?></td></tr>
<tr><td>high</td><td><?php echo $data[6]?></td></tr>
<tr><td>low</td><td><?php echo $data[7]?></td></tr>
</table>

<?php
fclose ($fp);
?>
<form>
ticker: <input type="text" size="30" name="stock" value="<?php echo $stock?>"><br />
<input type="submit" value="get quote">
</form>

<table><tr><td>
Most popular quotes
</td></tr>
<tr><td>
<a href="XOM">XOM</a> - Exxon Mobile
</td></tr>
<tr><td>
<a href="IBM">IBM</a> - IBM
</td></tr>
<tr><td>
<a href="GE">GE</a> - General Electric
</td></tr>
<tr><td>
<a href="WMT">WMT</a> - Wal-Mart
</td></tr></table>

The .htaccess file is:


RewriteEngine on
RewriteRule ^([a-z]+)$ stockquotes.php?stock=$1 [nc]

Any idea's?

coopster

12:36 am on Sep 27, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



What do the links look like (examplified please)? Is it the script that is not working, the rewritten url ...? Have you tried dumping the requested uri to see what is there?