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 8087625
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T18:50:17+00:00 2026-06-05T18:50:17+00:00

My application will be hosted in a shared hosting provider with a limit of

  • 0

My application will be hosted in a shared hosting provider with a limit of 25 Mysql concurrent connections. Below is my code for connecting to DB

function dbConnect() {
$dbHost = 'localhost';
$dbUser = 'user';
$dbPass = 'pass';
$dbName = 'dbase';  
    mysql_connect($dbHost, $dbUser, $dbPass)or die(mysql_error());
    mysql_select_db($dbName) or die(mysql_error());
   }

My application is more on database query. The home page alone has atleast 20 mysq_query in it. The way I code my home page is like below

include 'config.php';
dbConnect();

query1 … //to get initial variables

process variables that result in multiple query

query2… // process result

query3…// process result

and so on up to….

query 20…// process result

I cant minimize the query anymore coz most of the query is prerequisite of the other query. I am expecting of at least 1000 users daily, and the possibility of 50% of the users will connect on the same time or at lest seconds apart.

  1. On the design of connecting to DB will I easily reach the connection limit set?
  2. Is php closing the connection right after the query, meaning it closes after the first query, then open on the second and closes again right after, and so on and son, even if I’m not closing the connection myself
  3. Is my assumption correct that the above scenario automatically consumed 20 concurrent connections?

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 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-06-05T18:50:19+00:00Added an answer on June 5, 2026 at 6:50 pm

    For what it’s worth, some answers to questions 2. and 3. of genpet’s original post:

    1. PHP closes your connection to MySQL if and only if (assuming it wasn’t openned with mysql_pconnect()):

      • you call mysql_close()
      • you reach the end of the script
    2. Therefore, if you send 20 queries during the same script, you only consume 1 connection

    One thought just comes to my mind. Consider this pattern:

    • open/poll a connection with *_pconnect()
    • run a query, deal with the results
    • release the connection ASAP with *_close()
    • open/poll again if you need to query the DB later in the script

    This way, I believe one could work around the low concurrent connections limit (even though I agree with people advising your hosting plan may be inappropriate to fulfill your needs)

    This is theory, though, I haven’t tried that in the real.

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

Sidebar

Related Questions

I am working on a MVC 3 application that will be hosted in a
We have written Web application using ASP.NET MVC, which will be hosted in our
I am working on web application that will use PHP & MySQL. Application will
Seems simple but users have no internet access. The application will be hosted internally
Can I use the <%: tag on an application that will be hosted on
I am working on a MVC3 application that will be hosted on IIS7 with
I'm working on a web application that will be a hosted, multi-user solution when
I am designing a multi-tennant web-based SaaS application that will be hosted on Windows
Scenario I develop an MVC application that will be hosted in Windows Azure. During
Why does the code below work fine when I run my web application localhost

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.