The program only needs to connect once, you can either close the connection at the end of the function, open the connection in another function, or test if it's already connected before trying to connect.
If you can't connect, use the sql "GRANT" command, like
GRANT ALL ON *.* TO ODBC@localhost
I'm guessing the 2nd connect fails because require_once only includes the file once and on a 2nd call doesn't do anything because it's only used once.
It's best to move the connect code to the start of the program, like inside the config.php file, and move the require_once to the start of the program before the database is used.
Yea I figured it out earlier today, my solution checked to see if I required the config.php and if I did, it didn't set it again. I needed to include config.php in the function, so this worked out.