Solution for PHP Notice: Undefined index: internalid [closed]


I do not understand what is wrong with this code

//$expense_categories = explode(chr(13), $row[expense_categories]);
$categoryResult=mysqli_query($db,"SELECT category_id,category FROM expense_categories order by category_id");
if(mysqli_num_rows($categoryResult) > 0){
//echo mysqli_num_rows($categoryResult)."<br/><br/>\n";
    while($catrow = mysqli_fetch_assoc($categoryResult)){
        //echo $catrow["internalid"],"  ",$catrow["category"]."<br/>";
        $expense_categories[$catrow["internalid"]]=$catrow["category_id"]; //Linea 14

Error in log:


PHP Notice: Undefined index: internalid in   /var/www/ on line 14, referer:    link

asked by Martini002 30.03.2017 в 20:25

1 answer


The Error is simple, you can not access the Index internalid given that it is not part of your query SELECT , you can only access the Indices that you call in your query. That is, $catrow["category "] and $catrow["category_id"]

answered by 30.03.2017 / 20:35