Thanks for the suggestion. I added those three lines to the top of my script, and still didn't get any errors. I should have said it does not run correctly under CGI. It runs, but it is not adding the data to the database. I'm just getting the display page that says the data was uploaded successfully, but it wasn't.
I checked my permissions and they are the same as my other CGI scripts that work fine.