开发者

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']);
      }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜