Jump to content

Undefined Offset


michael.davis

Recommended Posts

Once again, as I look at my error_logs, I see another page that has a few errors.

 

[root@ohx-lw-tanager httpd]# tail -f error_log

[Wed Jul 11 13:07:17 2012] [error] [client 205.165.229.243] PHP Notice:  Undefined index: SPC in /sync/public/intranet/ohx/spc_feed.php on line 60, referer: http://www/

[Wed Jul 11 13:07:17 2012] [error] [client 205.165.229.243] PHP Notice:  Undefined offset: 1 in /sync/public/intranet/ohx/spc_feed.php on line 66, referer: http://www/

[Wed Jul 11 13:07:17 2012] [error] [client 205.165.229.243] PHP Notice:  Undefined index: SPC MD 1449\n        in /sync/public/intranet/ohx/spc_feed.php on line 60, referer: http://www/

[Wed Jul 11 13:07:17 2012] [error] [client 205.165.229.243] PHP Notice:  Undefined offset: 1 in /sync/public/intranet/ohx/spc_feed.php on line 66, referer: http://www/

[Wed Jul 11 13:07:17 2012] [error] [client 205.165.229.243] PHP Notice:  Undefined index: SPC Jul 11, 2012 1730 UTC Day 2 Convective Outlook\n      in /sync/public/intranet/ohx/spc_feed.php on line 60, referer: http://www/

[Wed Jul 11 13:07:17 2012] [error] [client 205.165.229.243] PHP Notice:  Undefined offset: 1 in /sync/public/intranet/ohx/spc_feed.php on line 66, referer: http://www/

[Wed Jul 11 13:07:17 2012] [error] [client 205.165.229.243] PHP Notice:  Undefined index: SPC Jul 11, 2012 1630 UTC Day 1 Convective Outlook\n      in /sync/public/intranet/ohx/spc_feed.php on line 60, referer: http://www/

[Wed Jul 11 13:07:17 2012] [error] [client 205.165.229.243] PHP Notice:  Undefined offset: 1 in /sync/public/intranet/ohx/spc_feed.php on line 66, referer: http://www/

[Wed Jul 11 13:07:17 2012] [error] [client 205.165.229.243] PHP Notice:  Undefined index: SPC Day 1 Fire Weather Outlook\n          in /sync/public/intranet/ohx/spc_feed.php on line 60, referer: http://www/

[Wed Jul 11 13:07:17 2012] [error] [client 205.165.229.243] PHP Notice:  Undefined offset: 1 in /sync/public/intranet/ohx/spc_feed.php on line 66, referer: http://www/

 

I am not sure why this is acting this way. I have hightlighted the areas in the code that the error log is point to. 

 

This wasnt an issue before, but now is.  Can anyone point out my issue?

 

Thanks!

Mike

 

 

<?php



# I'm including the open and close font tags so that undefined
# types will be handled gracefully. Since "Freeze Warning" is
# not defined, it's displayed in the default link color defined
# by the user. Class tags would be better than <font color=#xxxxxx>
# cuz then they would change color when selected.

$color_table = array(
    "Tornado Watch" => "<b><font color=#FF0000>,</font></b>",
"Severe Thunderstorm Watch" => "<b><font color=#FFA500>,</font></b>",
"Flash Flood Warning" => "<b><font color=#8B0000>,</font></b>",

);

$spcread_insideitem = false;
$spcread_tag = "";
$spcread_title = "";
$spcread_description = "";
$spcread_link = "";

function spc_startElement($spcread_parser, $spcread_name, $spcread_attrs) {
global $spcread_insideitem, $spcread_tag, $spcread_title,
	$spcread_description, $spcread_link;

if ($spcread_insideitem) {
	$spcread_tag = $spcread_name;
} elseif ($spcread_name == "ITEM") {
	$spcread_insideitem = true;
}
}

function spc_endElement($spcread_parser, $spcread_name) {
global $spcread_insideitem, $spcread_tag, $spcread_title,
	$spcread_description, $spcread_link, $color_table;
if ($spcread_name == "ITEM") {

	$title = split(' *- *', $spcread_title);
	[b]$font = split(',', $color_table[$title[0]])[/b];

	printf("<a target='_blank' href='%s'>%s%s%s</a><br>",
		trim($spcread_link),
		[b]$font[0],[/b]
		htmlspecialchars(trim($spcread_title)),
		[b]$font[1]);[/b]
	//printf("<span class='BodyText'>%s</span><br>",
	//	htmlspecialchars(trim($spcread_description)));
	$spcread_title = "";
	$spcread_description = "";
	$spcread_link = "";
	$spcread_insideitem = false;
}
}

function spc_characterData($spcread_parser, $spcread_data) {
global $spcread_insideitem, $spcread_tag, $spcread_title,
	$spcread_description, $spcread_link;

if ($spcread_insideitem) {
	switch ($spcread_tag) {

		case "TITLE":
		$spcread_title .= $spcread_data;
		break;

		case "DESCRIPTION":
		$spcread_description .= $spcread_data;
		break;

		case "LINK":
		$spcread_link .= $spcread_data;
		break;
	}
}
}

$spcread_xml_parser = xml_parser_create();
xml_set_element_handler($spcread_xml_parser,
"spc_startElement", "spc_endElement");

xml_set_character_data_handler($spcread_xml_parser, "spc_characterData");

$spcread_fp = fopen("http://www.spc.noaa.gov/products/spcrss.xml","r")
or die("Error reading RSS data.");

while ($spcread_data = fread($spcread_fp, 4096)) {
xml_parse($spcread_xml_parser, $spcread_data, feof($spcread_fp))
or die(sprintf("XML error: %s at line %d",
	xml_error_string(xml_get_error_code($spcread_xml_parser)),
	xml_get_current_line_number($spcread_xml_parser)));
}

fclose($spcread_fp);
xml_parser_free($spcread_xml_parser);

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.