What is the proper way to use mysql db on a multipage site?

From: Date: Fri, 26 Sep 2003 20:10:51 +0000
Subject: What is the proper way to use mysql db on a multipage site?
Groups: php.general 
Request: Send a blank email to php-general+get-164064@lists.php.net to get a copy of this message
I sent this to php-db with no reply, so I'll try it here then... -----Original Message----- From: Daevid Vincent [mailto:daevid@daevid.com] Sent: Wednesday, September 24, 2003 4:21 PM To: php-db@lists.php.net Subject: [PHP-DB] What is the proper way to use mysql db on a multipage site? I've been coding with PHP and mySQL for years. And this part has never sat right with me and finally I'm getting the nerve to ask how the pros out there do this... What I do is have a "db.php" file that contains: $db = mysql_connect ("localhost","username","password") or die ("Could not connect to SQL server."); mysql_select_db ("mydb",$db) or die ("Could not select Database"); Then at the top of every page, I require_once("db.php"); But it just seems so wasteful to keep making that mysql_connect(). Isn't there a way to store the $db result so I don't have to keep connecting. And how about the mysql_select_db() part too? Since I'm going to stay in the same db most of the time. I thought I read that I can't use a $_SESSION for it, and that's the only way I know of to have it be available on each page? Daevid Vincent http://daevid.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.general (#164064) next »