> -----Original Message----- > From: markus|lervik [mailto:[EMAIL PROTECTED]] > Sent: Friday, January 04, 2002 1:29 PM > > > > Example: > > > > <?php > > # Include the file containing general variables/constants/funstions > > require ("general.inc"); > > > > # Open a connection to MySQL using variables from general.inc > > $link = mysql_connect ($host, $username, $password); > > ?> > > > Yes, but then we come across the other problem, namely, if you click a > submit button that has a ACTION="<?php echo $PHP_SELF?>", technically the > script ends when it reloads the page, and therefore also forgets $host, > $username and $password, so I'd probably still have to somehow > register the > variables, ie. using session_register, no?
As long as you start all php files in your application by including the "general.inc" file, you will never lose these variables. The file "general.inc" may look like this: <?php $host = "127.0.0.1"; $username = "john"; $password = "secret"; ?> Just a word of caution.... Make sure that the file "general.inc" is NOT readable by the web server. Otherwise, it would be very easy to do a http://your.host/general.inc to reveal your database password. Regards, -Bjarte- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]