Using @One Trick Pony’s method, this should do what you want:
global $current_screen; // Makes the $current_screen object available
if ($current_screen && $current_screen->base == "edit") {
// Edit-page/post-only code here
}
If you want it on the add OR edit screens, then:
global $current_screen; // Makes the $current_screen object available
if ($current_screen && ($current_screen->base == "edit" || $current_screen->base == "post")) {
// Add-or-edit-page/post-only code
}