tarleton Posted December 11, 2009 Share Posted December 11, 2009 This script used to work fine on my local host however when treansfed to a live site i get the following output: echo $data['text']; ?> Here is code: <?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,'</span>:',$spos)+3; $spos = strpos($wrss,'<big>',$spos); $epos = strpos($wrss,'</div><h1>',$spos); if ($epos>$spos){ $text = substr($wrss,$spos,$epos-$spos); } else { $text = '-'; } $spos = $epos + 10; // Get company name $epos = strpos($wrss,'<',$spos); if ($epos>$spos){ $name = substr($wrss,$spos,$epos-$spos); } // Get actual price $spos = strpos($wrss,'yfs_l10')+strlen('yfs_l10'); $spos = strpos($wrss,'>',$spos)+1; $epos = strpos($wrss,'<',$spos); if ($epos>$spos){ $price = substr($wrss,$spos,$epos-$spos); } else { $price = '-'; } // Get direction $spos = strpos($wrss,'alt',$epos)+strlen('alt')+2; $epos = strpos($wrss,'"',$spos); if ($epos>$spos){ $dir = strtolower(substr($wrss,$spos,$epos-$spos)); } // Get difference $spos = strpos($wrss,'>',$epos+3)+1; $epos = strpos($wrss,'<',$spos); if ($epos>$spos){ $diff = substr($wrss,$spos,$epos-$spos); } } $result['name'] = $name; $result['value'] = $price; $result['diff'] = $diff; $result['direction'] = $dir; $result['text'] = $text; return $result; } // Get stock data //$data = processStockSite('c:\q.htm'); // Google $data = processStockSite('http://finance.yahoo.com/q?s=TLS.AX'); // Google //$data = processStockSite('http://finance.yahoo.com/q?s=MSFT'); // Microsoft //$data = processStockSite('http://finance.yahoo.com/q?s=AAPL'); // Apple //$data = processStockSite('http://finance.yahoo.com/q?s=GE'); // GE ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"> <html> <head> <title>Micro Stock</title> <link href="style/style.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="main"> <div id="caption"> </div> <div id ="icon2"></div> <div id="result"> <?php echo $data['text']; //echo $data['value'].' '; //if ($data['direction'] == 'up') echo '<span class="up"> +'.$data['diff'].'</span>'; //else echo '<span class="down"> -'.$data['diff'].'</span>'; ?> </div> </div> </body> ?> Help appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/184761-echo-problem-after-site-migration/ Share on other sites More sharing options...
cags Posted December 11, 2009 Share Posted December 11, 2009 You appear to have an unneeded closing tag at the end of your file, but that shouldn't cause any problems. There doesn't appear to be anything wrong with the code posted... Quote Link to comment https://forums.phpfreaks.com/topic/184761-echo-problem-after-site-migration/#findComment-975359 Share on other sites More sharing options...
tarleton Posted December 11, 2009 Author Share Posted December 11, 2009 I was really hoping you wouldn't say that. Quote Link to comment https://forums.phpfreaks.com/topic/184761-echo-problem-after-site-migration/#findComment-975365 Share on other sites More sharing options...
cags Posted December 11, 2009 Share Posted December 11, 2009 Is that your exact code? The most common cause of PHP code appearing on the client side is the developer using short_open_tags (<? rather than <?php) and them not being enabled on the server. I can't personally think of any other configuration setting that could cause only part of your PHP to appear on screen. Quote Link to comment https://forums.phpfreaks.com/topic/184761-echo-problem-after-site-migration/#findComment-975368 Share on other sites More sharing options...
tarleton Posted December 11, 2009 Author Share Posted December 11, 2009 I'm runnng the code in conjunction with a CMS called MODX but i don't see how that could cause a problem. Quote Link to comment https://forums.phpfreaks.com/topic/184761-echo-problem-after-site-migration/#findComment-975371 Share on other sites More sharing options...
PFMaBiSmAd Posted December 11, 2009 Share Posted December 11, 2009 When you do a "view source" of the page in your browser, what do you get? Specifically, is the raw php code at the top of the page visible or does the page start with the doctype output? Is the code in a file with a .php extension? Does any other .php page with some php code on it work as expected? I'm running the code in conjunction with a CMS called MODXDefine "in conjunction with"? Is the posted code an independent .php page that you are browsing to directly or is it some template or other content that the CMS is reading in? Quote Link to comment https://forums.phpfreaks.com/topic/184761-echo-problem-after-site-migration/#findComment-975387 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.