Custom fields won’t update

'name' is what gets saved as key in the post meta data, so do a str_replace for the category name, before saving:

// Wrong: name="My Category"
echo '<input type="checkbox"' . $i . 'name=".""'.$category->name.'"'.'value=""  />'.$category->name;

// Right: name="my_category"
$name = str_replace( ' ', '_', strtolower( $category->name ) );
$checked = get_post_meta( ...etc... );
echo "<input type="checkbox"{$i} name="{$name}" value="{$checked}"  />$name;