elseif (!ereg("^[0-9]{1,20}$",$gold))
what your old regex said was - if $gold contains 1 to 20 numerals. What this one says is if the first carater is a numeral and it is followed by 1 to 19 more numerals then it ends that's what the ^ and $ characters do. However this code will let you deposit 0 or 00 or 001 or you get the idea so I would recommend this code instead
elseif (!ereg("^[1-9][0-9]{0,19}$",$gold))
so that the first character must be between 1 and 9 followed by 0 to 19 more numerals then the end of the string.