PHP has a default maximum execution time of 30 seconds.
This means that by default, all PHP scripts will stop running after 30 seconds.
This is for server-safety, in case you accidently write something like
while (1)
{
// use large amounts of CPU
};
In your case, if the timeout happes at the database connect stage, you have probably typed the hostname of your database wrong, and PHP spends 30 seconds trying to get the IP for that name from the DNS, or the database doesn't respond within 30 seconds.
Can you access your database using the commandline mysql tools?