SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    Feb 2001
    Posts
    302
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    When I connect to a database which should I use mysql_connect() or mysql_pconnect()? Assuming that I am on a shared server and most of the pages on the site need to access a database.

    Also I have noticed in some PHP scripts that some people
    use mysql_close() at the end while others leave it out, is it important to use this at the end of the script?

    Thanks for any help - Neil

  2. #2
    exit();
    Join Date
    Jul 2000
    Posts
    759
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't really think that it is that important to use mysql_close if you're not using the persistant connection.

    I only use mysql_connect, not mysql_pconnect in my scripts, since a persistant connection would probably take up more server resources.

  3. #3
    SitePoint Wizard
    Join Date
    Apr 2000
    Posts
    1,483
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I generally use mysql_connect() - it does take much less resources.
    I never use mysql_close but I sometimes use mysql_free_result($result); which does help I think - eg:

    PHP Code:
    $query mysql_query("select * from whatever");
    while (
    $result mysql_fetch_array($query)) {
       echo 
    $result["qaz"];
    }
    mysql_free_result($result); 


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
  •