• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 311
  • Last Modified:

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

0
Cheryl Lander
Asked:
Cheryl Lander
  • 2
1 Solution
 
Marco GasiFreelancerCommented:
How is defined $assignedHash?
0
 
hieloCommented:
change:
if($assignedHash[$row['catid']])

to:
if( isset($assignedHash[$row['catid']]) )
0
 
Marco GasiFreelancerCommented:
Oh, yes... bhe, hielo is hielo...:-)
0
 
Cheryl LanderAuthor Commented:
Awesome guys.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now