php and undefined index

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.
<?php
        $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 = "";
			
	
            if($assignedHash[$row['catid']])
			
			

			$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

Cheryl LanderAsked:
Who is Participating?
 
hieloConnect With a Mentor Commented:
change:
if($assignedHash[$row['catid']])

to:
if( isset($assignedHash[$row['catid']]) )
0
 
Marco GasiFreelancerCommented:
How is defined $assignedHash?
0
 
Marco GasiFreelancerCommented:
Oh, yes... bhe, hielo is hielo...:-)
0
 
Cheryl LanderAuthor Commented:
Awesome guys.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.