--- cacti-0.8.5a/graphs_new.php	2004-04-01 17:48:04.000000000 -0500
+++ cacti-0.8.6/graphs_new.php	2004-04-22 22:07:16.000000000 -0400
@@ -518,12 +518,12 @@
 		$xml_array = get_data_query_array($snmp_query["id"]);
 		$xml_outputs = array();
 		
-		$total_rows = 0;
 		$num_input_fields = 0;
 		$num_visible_fields = 0;
 		
 		if ($xml_array != false) {
 			/* loop through once so we can find out how many input fields there are */
+			reset($xml_array["fields"]);
 			while (list($field_name, $field_array) = each($xml_array["fields"])) {
 				if ($field_array["direction"] == "input") {
 					$num_input_fields++;
@@ -535,6 +535,10 @@
 			}
 		}
 		
+		if (!isset($total_rows)) {
+			$total_rows = 0;
+		}
+		
 		/* we give users the option to turn off the javascript features for data queries with lots of rows */
 		if (read_config_option("max_data_query_javascript_rows") >= $total_rows) {
 			$use_javascript = true;
