PHP Error - Undefined Index problem

Posted on 2012-09-09
Medium Priority
Last Modified: 2012-09-09
I am receiving the following error:

A PHP Error was encountered

Severity: Notice

Message: Undefined index: Jun 10, 2011

Filename: controllers/taxCalcFunction.php

Line Number: 5

Open in new window

And here is the code in question:

	$arr_bill_dates = array();
	foreach($data['billing_events'] as $billdate) {
		foreach($billdate as $event) {
			$key = array_keys($event);
			$arr_bill_dates[$key[0]]++; } } //<- ERROR ON THIS LINE
	$data['arr_bill_dates'] = $arr_bill_dates;

Open in new window

I don't understand why I am getting this error because the variable $arr_bill_dates is defined at the beginning before the loop.  Why is this causing an error?  Thanks.
Question by:DanielAttard
  • 2
LVL 31

Accepted Solution

Marco Gasi earned 1000 total points
ID: 38381124
Because 'arr_bill_dates' is not recognized as a valid index for $data array, that is $data['arr_bill_dates'] item simply doesn't exist. I can't know why, but this is what you have to investigate.


Author Comment

ID: 38381139
Thanks for the advice.  I'll take a step back and look at some of the earlier code to see what's happening there.
LVL 111

Assisted Solution

by:Ray Paseur
Ray Paseur earned 1000 total points
ID: 38381144
You can use var_dump() to print out the contents of a variable.  It makes debugging a lot easier!

Author Comment

ID: 38381232
Thanks Ray.  I've implemented one of the many different flavors of debug tools found on the link you provided.  Now I've got tons of useful, well-formatted information being presented to me to help solve this issue.

Great idea.  Thank you.

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
Strategic internal linking is often considered an SEO power technique, especially for content marketing. Do you need to hire an SEO agency to optimize you internal linking? No, this article will help you understand the basics of internal linking and…
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…
Suggested Courses
Course of the Month13 days, 13 hours left to enroll

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question