I'm not sure how this is supposed to be done. Right now I'm just doing a
$db = mysql_connect( $dbServer, $dbUsername, $dbPassword );
mysql_select_db( $dbName, $db ) );
at the top of every page that accessed the database.
I've read somewhere that the database connections add a lot of overhead. Is that true? I've also read about establishing persistent connections with pconnect(), but are there any downsides to using them? It almost sounds to good to be true.
Indeed, persistent connections are too good not to use! :)
Basically, the only downside is the persistent connections. If for some reason you don't want connections open on your MySQL server all the time, you might not want to use it. Otherwise, there's no reason not to!
If you have a LOT of persistent connections, they take up some resources. But then you have to gauge the difference between taking up resources with pconnect's and the overhead of establishing a new connection.