[Webmakers] Webserver issue - databases

Janice Arrigan Janice.Arrigan at DoIT.ri.gov
Thu Oct 23 14:59:38 EDT 2014


Hi Karen
 
No expert, I do a little programming here and there. Think the original MySQL functions have been deprecated since PHP 5.5. We are using 5.1.6 so they still work for now. When I use $db=mysql_connect I also use mysql_close($db)
 
If you are interested in updating your code to MySQLi or PHP Data Objects (PDO), there is a great tutorial on lynda.com Accessing Databases with Object-Oriented PHP ( http://www.lynda.com/PHP-tutorials/Accessing-Databases-Object-Oriented-PHP/169106-2.html ) Subscriptions start at $25 per month. Highly recommended.
 
I watched the tutorial several times. Then began the process of updating my code to PDO.
 
Perhaps Al C. or Joyce C. have additional resources, ideas, code to share with the webmakers' group?
 
Janice

>>> "Karen Mellor" <Karen.Mellor at olis.ri.gov> 10/7/2014 11:33 AM >>>
Some of you who have pages that are supported through the state's database server may have noticed some issues this morning with pages not populating with data pulled in through mySQL databases on the state server.  For example, OLIS has a library search tool and continuing education course listings and registration set up with mySQL that were not working.
 
DoIT quickly fixed the problem, but let me know that this is a recurring problem and those of us using mySQL databases can help out by closing the connection to the database.  I am not that familiar with mySQL, so I cannot offer a solution, but we (OLIS) will be working on a solution for our website.  If anyone finds a solution and/or has more expertise in this area and would like to share, that would be super.
 
DoIT describes the problem this way:
 
It appears that the majority of Web Developers are using mysql_pconnect to make their connections to their DBs.
 
What is causing the problem is that they are NOT releasing or closing that connection when they exit their code.
 
This results in our running out of connections.
 
While pconnect is the preferred method of connecting to the DB, you MUST remember to release or close the connections when done!
 
If you don't wnat to close your connection, the just use mysql_connect.

Additional information:
 
Apparently there is no "pconnect close" option in PHP.
 
The simpler, better solution is to change mysql_pconnect to mysql_connect.
 
The latter drops the connection immediately when the web page closes.
 
Mysql_pconnect doesn't drop until the MySQL daemon is restarted or the server is rebooted which amounts to the same thing.
 
In 99.9% of the cases, pconnect is a bad idea.
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://listserve.ri.gov/pipermail/webmakers/attachments/20141023/36ab8407/attachment.html 


More information about the Webmakers mailing list