Link to home
Start Free TrialLog in
Avatar of jblayney
jblayneyFlag for Canada

asked on

undefined index errors

Hello,

I am getting undefined index errors and I cant see why.

This is one of my errors
Notice: Undefined index: hall_hst in /functions.php on line 2652

this is the code.

the query does produce the proper results, the page works fine of I turn off error reporting, but I want it perfect and want the notices gone.


$query_Recordset_get_reports = "SELECT all the things";
$Recordset_get_reports = mysqli_query($link, $query_Recordset_get_reports) 
or die(header(mysqli_error($link)));
$row_Recordset_get_reports = mysqli_fetch_assoc($Recordset_get_reports);
$totalRows_Recordset_get_reports = mysqli_num_rows($Recordset_get_reports);	



	if(($taxtype == "gst") || ($taxtype == "hst")) {
		
			if(isset($row_Recordset_get_reports['hall_gst'])) { 
			$row_Recordset_get_reports['hall_gst'] = $row_Recordset_get_reports['hall_gst'];
			} else {$row_Recordset_get_reports['hall_gst'] = 0.00;}
			
			if(isset($row_Recordset_get_reports['vendor_gst'])) { 
			$row_Recordset_get_reports['vendor_gst'] = $row_Recordset_get_reports['vendor_gst'];
			} else {$row_Recordset_get_reports['vendor_gst'] = 0.00;}
			
			if(isset($row_Recordset_get_reports['vendor_hst'])) { 
			$row_Recordset_get_reports['vendor_hst'] = $row_Recordset_get_reports['vendor_hst'];
			} else {$row_Recordset_get_reports['vendor_hst'] = 0.00;}
			
			if(isset($row_Recordset_get_reports['bei_hst'])) { 
			$row_Recordset_get_reports['bei_hst'] = $row_Recordset_get_reports['bei_hst'];
			} else {$row_Recordset_get_reports['bei_hst'] = 0.00;}
			
		
	//LINE 2652	
$final_sum = ($row_Recordset_get_reports['hall_gst'] + $row_Recordset_get_reports['vendor_gst'] + $row_Recordset_get_reports['bei_gst'] + $row_Recordset_get_reports['hall_hst'] + $row_Recordset_get_reports['vendor_hst'] + $row_Recordset_get_reports['bei_hst']);
		
		
	} 

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of David Favor
David Favor
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jblayney

ASKER

Hello David,

thank you for responding
isn't that what this is ?

if(isset($row_Recordset_get_reports['hall_gst'])) {
                  $row_Recordset_get_reports['hall_gst'] = $row_Recordset_get_reports['hall_gst'];
                  } else {$row_Recordset_get_reports['hall_gst'] = 0.00;}
No. That's hall_gst. You don't have a section of code for hall_hst.
You have 4 if(isset(....)) checks, but in line #2652 you're adding up 6 numbers.
@gr8gonzo

you are only seeing a small section of my code, i didn't want to swamp the forum with it all..

I have this for EVERY single variable, it still doesn't work.

if(isset($row_Recordset_get_reports['hall_gst'])) {
                  $row_Recordset_get_reports['hall_gst'] = $row_Recordset_get_reports['hall_gst'];
                  } else {$row_Recordset_get_reports['hall_gst'] = 0.00;}

Hi @Brain,

same answer, I gave a shortened version. I have this isset for every single variable yet still I get notices
If you exclude code but don't give any indication of what was excluded, then you might have excluded the problem code by accident.

Tthat undefined index would be a correct outcome for the code you've posted so far. So if you can share the full thing, that would help. Otherwise it's like taking your car to the mechanic and telling them the radio doesn't work but you removed the radio before going there. The mechanic sees a missing radio and tells you the radio doesn't work because it's not installed. We have to see the full picture (you can add helpful comments to indicate line numbers, etc).
Well, the code you re-posted (totally 3 times including the OP) was still for hall_gst but the PHP notice was for hall_hst.  I understand the reason why you didn't want to upload the whole script, but please at least show us the lines where you handled the hall_hst part? Maybe it's just a typo in you code, but if you don't show us the problematic part how can we help you?
You accepted a solution but it sounded like there was still an open question.
well David was correct, I just had to tweak and make sure they were being set, it was typos
Glad to hear you found the problem!