I have a login.php file that contains the username etc and logs into the database. I have used require_once("login.php") and also include("login.php") in other files. They both work. Which one should I use and when?
Also, how do I go about closing a database connection if I am including (or "requiring") a link to the login.php file? I have tried putting in mysql_close($databasename) in my php files but I just get an error message.
Sorry if this seems like two posts in one, but they are somewhat related.
Thanks
require or include??
Moderator: General Moderators
require or include??
Last edited by Indium on Mon Jul 22, 2002 9:36 pm, edited 1 time in total.
Closing the database
In response to closing the database, you stated you put:
mysql_close($databasename)
Just to make sure, since you said $databasename, you do mean $databaselink right? The mysql_close command works by closing a link not a dbname. Assuming that isn't the problem, to avoid the error message, you need some way of "closing" the db, only if you've opened it. So you could set a flag (some signifying variable, such as $dbflag = true), and then make the mysql_close command conditional. Ex:
if($dbflag) mysql_close($databaselink);
mysql_close($databasename)
Just to make sure, since you said $databasename, you do mean $databaselink right? The mysql_close command works by closing a link not a dbname. Assuming that isn't the problem, to avoid the error message, you need some way of "closing" the db, only if you've opened it. So you could set a flag (some signifying variable, such as $dbflag = true), and then make the mysql_close command conditional. Ex:
if($dbflag) mysql_close($databaselink);