A bit simpler and faster would be to use the [man]ctype_alnum/man function. If you want to do a regex, you should really use the [man]PCRE[/man] functions in preference to the ereg functions. In either case, you would need to anchor the beginning and ending of the regex to the begginning ("") and ending ("$") of the string:
preg_match('/^[a-z0-9]+$/i', $string);
If you really want to use eregi, just stick the same ^ and $ at the start/end of the regex.