SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2001
    Posts
    66
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    When to disconnect from mysql ?

    I read "Building a Database-Driven Web Site Using PHP and MySQL" and noticed that mysql_close(); is never used to close the connection. I found mysql_close(); in some other tutorial and would like to know when is it used and when not..

    Should a connection be always be cloased (after use) or is that not necessary ??

  2. #2
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You don't need to close connections MySQL will do it for you

    Sean
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature

  3. #3
    SitePoint Enthusiast
    Join Date
    Jul 2001
    Posts
    66
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    One more thing. When a connection is opened with MySQL on one page (for example page1.php) will it stay open for other pages linked to page1.php too ?

  4. #4
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you use persistent connections:
    http://www.php.net/manual/en/functio...l-pconnect.php

    Sean
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature

  5. #5
    SitePoint Enthusiast microair's Avatar
    Join Date
    Oct 2001
    Location
    My Computer
    Posts
    55
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well if you have included them in the php file and then you send query from them, yes it will take it... but not for hyperlinks... as soon as the page ends the connection is closed (for mysql_connect only) for pconnect the connection will not close...
    Last edited by microair; Nov 4, 2001 at 13:22.

  6. #6
    SitePoint Enthusiast
    Join Date
    Jul 2001
    Posts
    66
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanx a lot to both

  7. #7
    SitePoint Wizard Defender1's Avatar
    Join Date
    Apr 2001
    Location
    My Computer
    Posts
    2,808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It closes when the script exits, not the current page.
    Defender's Designs
    I'm Getting Married!

    Not-so-patiently awaiting Harry Potter Book 7 *sigh*


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •