You can use the standard WordPress function, get the dropdown already formatted and solve both problems at once.
Like so:
define( 'WP_USE_THEMES', false );
require( './wp-load.php' );
wp_dropdown_categories(
array(
'child_of' => 0,
'class' => 'postform',
'depth' => 0,
'echo' => 1,
'exclude' => '',
'hide_empty' => false,
'hide_if_empty' => false,
'hierarchical' => true,
'id' => '',
'name' => 'cat-dropdown',
'order' => 'ASC',
'orderby' => 'name',
'selected' => 0,
'show_count' => 0,
'show_option_all' => '',
'show_option_none' => __('None'),
'tab_index' => 0,
'taxonomy' => 'category',
)
);
Outputs:
<select name="cat-dropdown" id='cat-dropdown' class="postform" >
<option value="-1">None</option>
<option class="level-0" value="2">Other</option>
<option class="level-0" value="1">Uncategorized</option>
<option class="level-1" value="4"> Other</option>
<option class="level-2" value="5"> Other</option>
</select>
For the default category: