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

                $stmt2 = $db->query('SELECT catID, catTitle FROM blog_cats ORDER BY catTitle');
                while($row2 = $stmt2->fetch()){
                    if(in_array($row2['catID'], $_POST['catID'])){
                            $checked = null;

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



Recommended Answers

All 2 Replies

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.