Notice: undefined offset???
Posted: Sat Dec 30, 2006 3:20 pm
I noticed that when I curl information off webpages on stocks, they will simply have no data recorded. When a stock has nothing to yield in data it returns this notice:
a good example of this would be ticker symbol, ARC1A. I typically get the notice when the website it self doesn't recognize the ticker as a valid stock/bond/security. Could someone explain what is this notice telling me exactly and how do I correct it?Notice: Undefined offset: 1 in /home/clinton/hdd1/coldowl/project/stock/tests/stock_class.php on line 287
Code: Select all
<?php
class example{
var $dividend;
function mysql_dividend($ticker){
$url = "http://www.zacks.com/research/report.php?type=detailed&t=".$ticker;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_TIMEOUT, 3);
$result = curl_exec($ch);
curl_close($ch);
$pattern='!Dividend</td>\s*<td\s*align=right\s*width=50%\s*class="ticker">([^<]*)</td>!';
preg_match($pattern,$result,$this->dividend);
echo $this->dividend[1]
}
}
?>