Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 296607
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T06:33:50+00:00 2026-05-12T06:33:50+00:00

I am using MySQL 5.0 for a site that is hosted by GoDaddy (linux).

  • 0

I am using MySQL 5.0 for a site that is hosted by GoDaddy (linux).

I was doing some testing on my web app, and suddenly I noticed that the pages were refreshing really slowly. Finally, after a long wait, I got to a page that said something along the lines of “MySQL Error, Too many connections…”, and it pointed to my config.php file which connects to the database.

It has just been me connecting to the database, no other users. On each of my pages, I include the config.php file at the top, and close the mysql connection at the end of the page. There may be several queries in between. I fear that I am not closing mysql connections enough (mysql_close()).

However, when I try to close them after running a query, I receive connection errors on the page. My pages are PHP and HTML. When I try to close a query, it seems that the next one won’t connect. Would I have to include config.php again after the close in order to connect?

This error scared me because in 2 weeks, about 84 people start using this web application.

Thanks.

EDIT:

Here is some pseudo-code of my page:

 require_once('../scripts/config.php');

 <?php
    mysql_query..

    if(this button is pressed){
       mysql_query...
    }
    if(this button is pressed){
       mysql_query...
    }
    if(this button is pressed){
       mysql_query...
    }
 ?>
 some html..
 ..
 ..
 ..
 ..
 <?php
   another mysql_query...
 ?>
 some more html..
 ..
 ..
 <?php mysql_close(); ?>

I figured that this way, each time the page opens, the connection opens, and then the connection closes when the page is done loading. Then, the connection opens again when someone clicks a button on the page, and so on…

EDIT:

Okay, so I just got off the phone with GoDaddy. Apparently, with my Economy Package, I’m limited to 50 connections at a time. While my issue today happened with only me accessing the site, they said that they were having some server problems earlier. However, seeing as how I am going to have 84 users for my web app, I should probably upgrade to “Deluxe”, which allows for 100 connections at a time. On a given day, there may be around 30 users accessing my site at a time, so I think the 100 would be a safer bet. Do you guys agree?

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T06:33:50+00:00Added an answer on May 12, 2026 at 6:33 am

    Shared-hosting providers generally allow a pretty small amount of simultaneous connections for the same user.

    What your code does is :

    • open a connection to the MySQL server
    • do it’s stuff (generating the page)
    • close the connection at the end of the page.

    The last step, when done at the end of the page is not mandatory : (quoting mysql_close‘s manual) :

    Using mysql_close() isn’t usually
    necessary, as non-persistent open
    links are automatically closed at the
    end of the script’s execution.

    But note you probably shouldn’t use persistent connections anyway…

    Two tips :

    • use mysql_connect insead of mysql_pconnect (already OK for you)
    • Set the fourth parameter of mysql_connect to false (already OK for you, as it’s the default value) : (quoting the manual) :

    If a second call is made to
    mysql_connect() with the same
    arguments, no new link will be
    established, but instead, the link
    identifier of the already opened link
    will be returned.

    The new_link
    parameter modifies this behavior and
    makes mysql_connect() always open a
    new link, even if mysql_connect() was
    called before with the same
    parameters.


    What could cause the problem, then ?

    Maybe you are trying to access several pages in parallel (using multiple tabs in your browser, for instance), which will simulate several users using the website at the same time ?

    If you have many users using the site at the same time and the code between mysql_connect and the closing of the connection takes lots of time, it will mean many connections being opened at the same time… And you’ll reach the limit 🙁

    Still, as you are the only user of the application, considering you have up to 200 simultaneous connections allowed, there is something odd going on…


    Well, thinking about “too many connections” and “max_connections“…

    If I remember correctly, max_connections does not limit the number of connections you can open to the MySQL Server, but the total number of connections that can bo opened to that server, by anyone connecting to it.

    Quoting MySQL’s documentation on Too many connections :

    If you get a Too many connections
    error when you try to connect to the
    mysqld server, this means that all
    available connections are in use by
    other clients.

    The number of connections allowed is
    controlled by the max_connections
    system variable. Its default value is
    100. If you need to support more connections, you should set a larger
    value for this variable.

    So, actually, the problem might not come from you nor your code (which looks fine, actually) : it might “just” be that you are not the only one trying to connect to that MySQL server (remember, “shared hosting”), and that there are too many people using it at the same time…

    … And if I’m right and it’s that, there’s nothing you can do to solve the problem : as long as there are too many databases / users on that server and that max_connection is set to 200, you will continue suffering…

    As a sidenote : before going back to GoDaddy asking them about that, it would be nice if someone could validate what I just said ^^

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 237k
  • Answers 237k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Use the :not() selector. E.g. $("#list li:last:not(.action)").addClass("active"); May 13, 2026 at 6:41 am
  • Editorial Team
    Editorial Team added an answer I'm sad that I didn't get any answers from the… May 13, 2026 at 6:41 am
  • Editorial Team
    Editorial Team added an answer I think it's probably due to this issue, described on… May 13, 2026 at 6:41 am

Related Questions

Below is just a mockup of 2 codes in php/mysql. The first one returns
I want to know when building a typical site on the LAMP stack how
I am currently creating a type of classifieds website, and when the user enters
OK, I have just been reading and trying for the last hour to import

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.