Using PHP to echo into URL
Hi
I am trying to include the code xta into this below url, it works with other parts on the page, but there is something to do with this URL that appears to stop it working. Would anyone be able to tell me why xta does not get inserted where the <?=$code?> is?
<?php
$code = "xta";
?>
$data = processStockSite('http://finance.yahoo.com/q?s=<?=$code?>.l');
Thanks in advance
gilgil2
Junior Poster in Training
68 posts since Aug 2011
Reputation Points: 10
Solved Threads: 1
almostbob
Posting Sensei
3,149 posts since Jan 2009
Reputation Points: 571
Solved Threads: 376
Thanks for the quick reply
I have tried the things you suggested but nome of them work for me. I am not sure what I am doing wrong. I have posted some more code, maybe you can spot the problem? I would be very grateful.
I have changed it a little bit so that the echo is the file name, but it is essentially the same. The echo works elsewhere, and in other URLs but still not this one.
<?php
function getStockSite($stockLink){
if ($fp = fopen($stockLink, 'r')) {
$content = '';
while ($line = fread($fp, 1024)) {
$content .= $line;
}
}
return $content;
}
function processStockSite($wurl){
$wrss = getStockSite($wurl);
$name = '-';
$price = '';
$diff = '';
if (strlen($wrss)>100){
$spos = 0;
// Get text
$spos = strpos($wrss,':',$spos)+3;
$spos = strpos($wrss,'',$spos);
$epos = strpos($wrss,'
gilgil2
Junior Poster in Training
68 posts since Aug 2011
Reputation Points: 10
Solved Threads: 1
almostbob
Posting Sensei
3,149 posts since Jan 2009
Reputation Points: 571
Solved Threads: 376
That worked! Thank you so much, you have saved me a lot of time!
gilgil2
Junior Poster in Training
68 posts since Aug 2011
Reputation Points: 10
Solved Threads: 1
almostbob
Posting Sensei
3,149 posts since Jan 2009
Reputation Points: 571
Solved Threads: 376