in reply to working with a database
"can anyone point me in the right direction for modifying my code to prevent this?"
Probably not, because you don't show us enough code. How is %phonebook populated? My guess is that it gets updated each time a name is added, but that you don't populate it with the names already in the database.
Note that it is often a dumb idea to have the same information in two places because if it gets out of sync you can end up with very hard to find bugs. The main exception is where you cache data for fast access, which may be the case here. However if the updates are infrequent I'd get rid of %phonebook and check the database first to see if the name is there already.
|
|---|