Persisting MySQL connection accross scripts

From: Date: Sat, 01 Nov 2003 18:19:49 +0000
Subject: Persisting MySQL connection accross scripts
Groups: php.general 
Request: Send a blank email to php-general+get-168280@lists.php.net to get a copy of this message
How can I establish a connection with a MySQL database and have it persist accross multiple script files? I've found the mysql_pconnect() function but this doesn't seem to do the job - which is fairly logical actually because the connection is stored in a variable: $connect = mysql_pconnect(); and that variable $connection won't be available in another script. I would have thought there would be a straightforward answer to this as it seems that its someting which must be done fairly regularly. The only workaround I can think of is sending the username, password and database name to every script. But how would you do this securely? When establishing the initial connection I got the username and password from a form which used the method="POST" method. But if I want to have a link to a script, say 'add_item.php', how can I do it securely? <a href="add_item.php?username=<? echo($_POST['username']): ?>&password=<? echo($_POST['password']): ?>&..."></a> would not use the POST method. I could use forms for every link but this seems ridiculously over-complicated! Thanks in advance for any pointers! Richard. -- UEA/MUS

« previous php.general (#168280) next »