0

In while loop I'm assigning value pulled from DB to the array like so:

$states[$row['state']]

PHP gives me the following notice:

Notice: Undefined index: ME in /var/www/vhosts/basementfinishing-md-de.com/httpdocs/inc/class.cityBlock.php on line 67

What I'm doing wrong here?

1
  • Try a var_dump($states); and see if there's any key called 'ME' in the array. Or, var_dump($row) to make sure you're fetching the right data. Commented Oct 11, 2010 at 14:58

2 Answers 2

1

It means $row['state'] is 'ME' and this index is not defined for $states.

Sign up to request clarification or add additional context in comments.

Comments

0

I don't have enough context to interpret the error message 100%, but I've been known to do something like this:

      $states = array();
      while ($row = mysql_fetch_assoc($result)) {
        array_push($states, $row['state']);
      }

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.