Stop script running if it fails to connect/select db

If the script fails it goes ahead and creates the duplicate database, which then causes the script to fail somewhere else when ran again. This will stop the script when it fails in the first instances, stopping anything else being done/created.