Re: mysql_pconnect - persistance scope?
| From: | Robert Gormley | Date: | Wed, 10 Oct 2001 06:34:19 +0000 |
| Subject: | Re: mysql_pconnect - persistance scope? | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-13182@lists.php.net to get a copy of this message | ||
Persistence is referring to the PHP engine holding open the mysql connection.
I usually make an include file:
define("HOST", "hostname");
define("USER", "user");
define("PASSWORD", "pw");
define("DATABASE", "db");
function dbConnect()
{
mysql_pconnect(HOST, USER, PASSWORD);
mysql_select_db(DATABASE);
}
and then in each page where db access is required:
require("includes/database.inc");
dbConnect();
Rgds,
Robert
At 04:44 PM 9/10/2001 -0700, Youngie wrote:
I have a question about mysql_pconnect. I execute it in one file logon.php and successfully do some db queries, later on in another file xyz.php I do some other queries but they fail. It works OK if I repeat the mysql_pconnect() and the mysql_select_db() in that file, is the persistance only across a single script? i.e. do I have to do a pconnect for every php file that does db access? If I do, how do I store the original userid and password to make them global to all php scripts. If I don't then what could the problem be? Some kind of timeout? Thanks John.