Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 5 of 5
  1. #1
    Senior Member joncom11's Avatar
    Join Date
    Oct 2003
    Posts
    284
    Member #
    3532
    I have a site that recieves over 10,000 unique hits per day... I am finally beginning to notice that my site requires a decent server in order to keep it running well.

    I'm finding that I'm often getting mySQL problems now saying something about 'user_max_connections" to mySQL database, which fixes itself over a few minutes. But these moments of downtime are very irritating. My entire site uses forum integration, so mySQL is being used CONSTANTLY. I also use mySQL a LOT for other things.

    I'm wondering how I can reduce this problem. I know there is functions like mysql_close() or close()... something like that. If I'm correct, these are used to free resources. I never really use them though. Would it help if I used such functions?
    Pixel Fuse - Signature webpage, just a spashpage.
    Flash Frogger - Frogger remake, animated/coded in Flash (incomplete/discontinued)
    Daase Art Studio - Homepage of David Daase, a Canadian landscape artist - image gallery/showcase.
    More links if I think of some...

  2.  

  3. #2
    Senior Member
    Join Date
    May 2003
    Location
    UK
    Posts
    2,354
    Member #
    1326
    If you use MYSQl often, as I am sure you do, you should use mysql_pconnection.

    And, with mysql_pconnection, which means persistent connectin, you should use mysql_close.

    The pconnection command is used over multiple pages, such as a cms, or a forum.

    So, you should use mysql_close.

    I am not sure if it will have a noticeable effect though.

  4. #3
    Senior Member rosland's Avatar
    Join Date
    Jul 2003
    Location
    Norway
    Posts
    1,944
    Member #
    2096
    Quote Originally Posted by joncom11
    I never really use them though. Would it help if I used such functions?
    Yes, as the connections made by your script, stays open after your script closes. (the amount of connections allowed, and how long each connection is allowed to stay idly open, can be specified in the my.ini file of MySQL. Normally outside your control if your on a hosted server)

    If you use mysql_pconnect(), the script looks for already open connections and utilizes these (if found) instead of opening a new connection. The 'persistent connections' is though deprecated in later versions of PHP and MySQL.

    You should always terminate connections towards the end of your script, as this is a resource that is independant of your script (meaning it doesn't die together with your script).

    $con=mysql_open(...);

    // script

    mysql_close($con);
    S. Rosland

  5. #4
    Senior Member joncom11's Avatar
    Join Date
    Oct 2003
    Posts
    284
    Member #
    3532
    Taken from http://php.net/mysql_close
    Using mysql_close() isn't usually necessary, as non-persistent open links are automatically closed at the end of the script's execution.
    Are you sure that it would help closing connections if they are just to be closed anyways?
    Pixel Fuse - Signature webpage, just a spashpage.
    Flash Frogger - Frogger remake, animated/coded in Flash (incomplete/discontinued)
    Daase Art Studio - Homepage of David Daase, a Canadian landscape artist - image gallery/showcase.
    More links if I think of some...

  6. #5
    Senior Member rosland's Avatar
    Join Date
    Jul 2003
    Location
    Norway
    Posts
    1,944
    Member #
    2096
    Hmmm...
    I thought I was, until I followed your link (?)

    I've always used mysql_close, from the first time I started learning MySQL. I seem to remember the reason given was the one I gave you above. Maybe I recall incorrectly, or maybe they changed the way things work.

    Apperantly, you cannot terminate connections made by mysql_pconnect (through mysql_close() )either, which I was unaware of.

    So, in short, I have to look deeper into that one (unless someone else have a soultion). It would appear you've exceeded max allowable connections to your DB (which could be altered in the my.ini file), but other than that, I have no suggestions as of now.
    S. Rosland


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 03:22 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com