Toll Free Telephone: 800.385.8350 | Local: 262.671.2023 | Mon-Sat 12am-11:59pm
My Code Teacher
Red Cross
Online Support Chat
home
login to account
lessons
free lessons
forum
contact us
register now
MyCodeTeacher Forum
September 04, 2010, 12:34:12 PM
Welcome,
Guest
. Please
login
or
register
.
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
News
: MyCodeTeacher forum launched!
Home
Help
Search
Login
Register
MyCodeTeacher Forum
>
PHP
>
PHP Beginner
>
Closing connection to SQL database
Pages: [
1
]
« previous
next »
Print
Author
Topic: Closing connection to SQL database (Read 443 times)
Ronald Dear
Newbie
Posts: 19
Closing connection to SQL database
«
on:
April 18, 2010, 12:42:07 PM »
I've noticed that after a while working with tables in a database I sometimes get an error complaining of too many connections and then I can no longer even log into phpMyAdmin. After some digging I found out that you need to close a connection after you are done with it or else it remains open. I have been using the line:
include("sql.php");
in my php documents that use a db. In that document I have the lines:
$connection = mysql_connect(....)
$database = mysql_select_db(....., $connection)
My question is, do I need to have those lines in the document that uses the DB or can I just call
mysql_close($connection);
in the document that has the include("sql.php"); or do i actually have to have the connection and database lines in the file as well?
Thanks in advance for any help!
Logged
Masna
Administrator
Full Member
Posts: 103
Re: Closing connection to SQL database
«
Reply #1 on:
April 21, 2010, 09:28:55 PM »
Simply...
Code:
mysql_close();
...should work.
Anthony
Logged
Loren Hills
Newbie
Posts: 27
Re: Closing connection to SQL database
«
Reply #2 on:
May 17, 2010, 11:04:13 AM »
I agree with Anthony. Also you may want to include it when ever you are done with a connection as is. This should prevent you from leaving connections open on accident. You could also include it in your footer file if you have one.
Logged
Thanks,
Loren
Linux and cPanel Instructor
Pages: [
1
]
Print
« previous
next »
Jump to:
Please select a destination:
-----------------------------
General
-----------------------------
=> General Discussion
-----------------------------
iPhone SDK
-----------------------------
=> General iPhone Programming
=> iPhone SDK Beginner
=> Foundation Programming
=> UIKit Programming
=> Other Frameworks
-----------------------------
PHP
-----------------------------
=> General PHP Programming
=> PHP Beginner
=> Math
=> PHP Applications
-----------------------------
Photoshop
-----------------------------
=> General Photoshop Help
Loading...
Copyright © MyCodeTeacher.com 2009. All rights reserved!
Terms of Service
Template Design
by 89Bytes Web Studio