
Hello, I have a website with more than 50 pages. Each page is configured to connect to my SQL database to query data. However, most of times my web pages displays the error message" Too many Connection". I know that this is because of too many connections are requested from SQL server at same time and causes the server to overload, but I am seeking to find out the solution for this.
In most discussion forums, I see advices to get a dedicated hosting package rather than shared, but I have a few Joomla website which are using the same shared hosting packages with no such error while joomla is also using MySQL.
If I have thousands of people using my joomla website and viewing hundreds of pages, I wont get any connection error and the truth is that Joomla is also using MySQL.
The question is that why I get error messages when I manually make a connection to MySQL database in my web pages? How joomla is connection to MySQL without getting any connection error?
For reference, My last website had 2 pages, each 2 script block to connect the database, when I have about 10 users at the same time, I get the connection error.
If MySQL is not suitable for only 10 users, then what is the benefit of using it?
below is the code how I am connecting to MySQL: I am connection to MySQL database in 2 different sections of my web page.
<div class="sidebox">
<img src="images/weare.jpg"><br><br><div style="width: 298px">
<?
include("admin/db.php");
$query = mysql_query("select * from pages where pagename='home' limit 1");
while($row = mysql_fetch_array($query))
{
echo "<p>".$row["data"]."</p>";
}
mysql_close($con);
?>
</div>
</div>
<div class="imagebox">
<div class="slideshow">
<img src="images/image1.jpg" />
</div>
<div style="clear:both"></div><br>
<br>
<div style="width: 303px; height: 264px; float:left; padding-left:10px; padding-right:10px;">
<?
include("admin/db.php");
$query = mysql_query("select * from pages where pagename='box1' limit 1");
while($row = mysql_fetch_array($query))
{
echo "<p>".$row["data"]."</p>";
}
mysql_close($con);
?>
</div>
An other question is that how I can properly connect to my SQL database where I need to display information in different sections of my web pages from different database tables? Do I need to open one connection to each section?
Thank you,
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.