The important things required to connect DB from scripts ( PHP,CGI or Perl ) are :

database server : localhost
database name : cpanel username_testdb
database username : cpanel username_dbuser
database user password : *****