The straightforward answer to this (and it is done fairly regularly) is that you require() a file that reads configuration (usualy another file) and connects to the database, and also does other usefull things.
rich wrote:
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.n
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.
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php