php and undefined index

Posted on 2011-04-26
Last Modified: 2012-05-11
I have some code below which retrieves values from mysql and outputs them as a series of checkboxes.

This works fine.

Only problem is if a value inst checked (ticked) it comes up with an error of

Notice: Undefined index: 198 in C:\wamp\www\edit_item.php on line 207

Line 207 = if($assignedHash[$row['catid']])

Any help would be appreciated.
        $query = 'SELECT catid, catname FROM categories ORDER BY pageorder';
        $ret = mysql_query($query) or die('Cannot execute query');
        while ($row = mysql_fetch_assoc($ret)) {
            $checked = "";

			$checked = " checked='checked'";

            echo "<label><input type='checkbox' name='catid[]' value='{$row['catid']}' {$checked}/>  {$row['catname']} - {$row['catid']}</label><br />\n";

Open in new window

Question by:Cheryl Lander
    LVL 30

    Expert Comment

    by:Marco Gasi
    How is defined $assignedHash?
    LVL 82

    Accepted Solution


    if( isset($assignedHash[$row['catid']]) )
    LVL 30

    Expert Comment

    by:Marco Gasi
    Oh, yes... bhe, hielo is hielo...:-)

    Author Closing Comment

    by:Cheryl Lander
    Awesome guys.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Join & Write a Comment

    Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
    Read about why website design really matters in today's demanding market.
    This video teaches users how to migrate an existing Wordpress website to a new domain.
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now