I have a PHP page that references an include file to get database information. That same page interacts with the database and I have a mysql_close($db_connect) statement at the end.
However, I also have a function that is referenced in the middle of the code. That function lives in a separate include file and also uses the database. I have mysql_close($db_connect) statements in the include file as well.
The issue I’m having is that any database calls that occur on the main page AFTER the function has executed fail because the database connection has been closed. I know this may be a newbie question but should I just not close the DB connection in my include files or am I going about this all the wrong way?
Thank you!
mysql_close() closes the non-persistent connection to the MySQL server that’s associated with the specified link identifier.
Using mysql_close() isn’t usually necessary, as non-persistent open links are automatically closed at the end of the script’s execution.
Check out this link below:
http://www.php.net/manual/en/language.types.resource.php#language.types.resource.self-destruct
I hope this helps