Undefined index when assigning value to array element
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/开发者_StackOverflow中文版class.cityBlock.php on line 67
What I'm doing wrong here?
It means $row['state']
is 'ME' and this index is not defined for $states
.
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']);
}
精彩评论