What I normally do when I need different connection information is to duplicate the connection file, then just update the values in it for the live server. When you upload all of the files make sure to upload the connection file that has the same name but with the server address, username, password, and db mentioned. As far as the code is concerned it does not matter what these values are set to, just that the connection file has the same name, is in the same spot, and the variables inside of it are named the same. The only thing that should be different is the values that the variables are set to.
As for the code I'm not sure why it would be written incorrectly for you. What is the OS and DW version that you are working with? Does it do this all the time for every site or is it specific to the site you are currently working with? Have you tried completely uninstalling and removing the extension then installing it again? There might be a problem with the current install.
Let us know how this goes for you.