The correct code to be replace would be

if (!is_null($categories_image->filename)) {
tep_db_query("update " . TABLE_CATEGORIES . " set categories_image = '" . tep_db_input($categories_image->filename) . "' where categories_id = '" . (int)$categories_id . "'");
}

There was an extra } at the end>>
// if (!is_null($categories_image->filename)) {
tep_db_query("update " . TABLE_CATEGORIES . " set categories_image = '" . tep_db_input($categories_image->filename) . "' where categories_id = '" . (int)$categories_id . "'");
}
}
//

Credits to Abhinav Vishwanathan

More...