Hey guys i need help, I dont know how to remove that irritaing notice....here's the code

<fieldset>
            <legend>Categories</legend>
            <?php    
                $stmt2 = $db->query('SELECT catID, catTitle FROM blog_cats ORDER BY catTitle');
                while($row2 = $stmt2->fetch()){
                if(isset($_POST['catID'])){
                    if(in_array($row2['catID'], $_POST['catID'])){
                        $checked="checked='checked'";}
                        else{
                            $checked = null;
                }
            }

//this is where it says undefined variable      echo "<input type='checkbox' name='catID[]' value='".$row2['catID']."' $checked> ".$row2['catTitle']."<br />";
    }

    ?>

</fieldset>

The variable $checked is not defined when there are no results, so I suggest to move line 10 to between line 4 and 5, and replace null with '' (empty string).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.