in reply to working with a database

If you make name a primary key in your database, you cannot enter a second entry for the same name. Instead of querying the database, you can then just run the insert query, and inspect the error (if any). Or you could make your query:
-- MySQL syntax INSERT INTO Pnonebook (name, Phone) VALUES (?, ?) ON DUPLICATE KEY UPDATE Phone=VALUES(Phone)
which stores the most recent phone number.