Question: Connection to Database

Ads

 
 
 

Share on Google+Share on Google+

shuja
Connection to Database
0 Answer(s)      5 years and 5 months ago
Posted in : PHP

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,

Ads
View Answers
Ads









Related Tutorials/Questions & Answers:
DataBase Connection
DataBase Connection  How to connect java and Oracle 10g? Tell me Jdbc connection
Connection to Database
I manually make a connection to MySQL database in my web pages? How joomla... is the code how I am connecting to MySQL: I am connection to MySQL database in 2... database tables? Do I need to open one connection to each section? Thank you
Advertisements
database connection
database connection  how to connect the jsp page with database
database connection
database connection  i wanted to no how to connect sqlite database through netbeans? is it posible to connect it to a database that is on a remote pc? thank you
JAVA DATABASE CONNECTION WITH JTABLE
JAVA DATABASE CONNECTION WITH JTABLE  HOw To Load Database Contents From Access Database to JTable without using Vector
J2ME with Database Connection - MobileApplications
J2ME with Database Connection  I'm using SonyEricssion Java ME SDk for CLDC with WTK2. Can u give me a sample program for Database Connection using MS-Access with MIDlet code
DataBase connection with sql - Struts
DataBase connection with sql  How to connect sql and send db error in struts? what are the tag should i code in struts-confic.xml
database connection in struts - Struts
database connection in struts  Connecting database in Struts  in my project 4 table 1.user register 2.login page 3.forgot password 4.welcome page. all in struts but i dont no how sql database connected in struts plz
connection with database - JSP-Servlet
and the connection with the database using jsp code, I get exceptions that I have... with java code. Is there any other way to establish a connection with database in jsp... a connection with database. Plz reply. Thanks in advance...   Hi
database connection - SQL
-database connection in eclipse IDE? Thanks...database connection  hi friends, This is poornima i want to connect sql server to my eclipse editer how to connect and where i have to write code
Connection to database - Java Beginners
Connection to database   HI I have just Started working on a Project on Jsp We hve some JSP Pages & trying to connect to our Database . We are using SQL server 2000 ? We are not able to connect our database Tables
java database connection - JDBC
java database connection  sir i want to join my project with MS access database. i am making my project in netbeans.please tell me the coding to do... the data into the MS Access database and retrieve the data from the database table
Regading Database connection
Regading Database connection  if we create the query table means how we retrive the query content from database
connection database error
connection database error  import java.awt.EventQueue; // import packages import java.awt.event.ActionEvent; import java.awt.event.ActionListener...{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection
error oracle database connection?
error oracle database connection?  hi now i am trying to connect oracle database and also insert my data into table, but it's not working.. I created...; PreparedStatement stmt=null; Connection con =null; ResultSet rs=null
Database Connection - JDBC
Database Connection  In java How will be connect Database through JDBC?  Hi Friend, Please visit the following link: http://www.roseindia.net/jdbc/jdbc-mysql/MysqlConnect.shtml Thanks
Java Connection to Oracle database
Java Connection to Oracle database  HI I am ubable to connnect jdbc to Oracle database.i had gone to control panel >>Administrative... type properly and the Test Connection failed.So Kindly tell me what to type in TNS
java database connection - Struts
java database connection  how to connect a database in struts program?  First Add two jar file1> commons-dbcp-1.2.x.jar2> mysql...; value="jdbc:mysql:///database_name?autoReconnect=true"
java database connection
java database connection  package com.tsi.constants; public class Constant { public static final String DRIVER = "oracle.jdbc.driver.OracleDriver"; public static final String DBURL = "jdbc:oracle:thin
java database connection
java database connection  package com.tsi.constants; public class Constant { public static final String DRIVER = "oracle.jdbc.driver.OracleDriver"; public static final String DBURL = "jdbc:oracle:thin
Database connectivity Hibernate mysql connection.
Database connectivity Hibernate mysql connection.  How to do database connectivity in Hibernate using mysql
Database connection class in a live project ..??
Database connection class in a live project ..??  In a Live mvc project where should i put the database connection class ? I want to know in the best coding practice
android connection to database oracle 10g
android connection to database oracle 10g  Hello, How i can connect my android application to my oracle 10g database
database connection in javascript - Java Beginners
database connection in javascript  hi, How can i connect the database and insert the data's by using javascript. thank u in advance. ragards, sakthi
database connection by using java bean
database connection by using java bean  i need a code for bean class to connect to mysql database. subsequently to use dis bean class whereever i need 2 connect 2 database
server database connection - JSP-Servlet
" in that case how we will get the database connection   Hi Friend...server database connection  sir generally we will connect to the database by using the following steps 1.Class.forName("sun.jdbc.odbc.JdbcOdbcDriver
About connection database oracle to java
About connection database oracle to java  Hi I culdn't connect oracle datebase to java.when i compile the program it is ok.but when i clicked... to verify that connection is correct or not.The testing has failed .so what could
About connection database oracle to java
About connection database oracle to java  Hi I culdn't connect oracle datebase to java.when i compile the program it is ok.but when i clicked... to verify that connection is correct or not.The testing has failed .so what could
About connection database oracle to java
About connection database oracle to java   I culdn't connect oracle datebase to java.when i compile the program it is ok.but when i clicked on sql... that connection is correct or not.The testing has failed .so what could be TNS
About connection database oracle to java
About connection database oracle to java  **Hi I culdn't connect oracle datebase to java.when i compile the program it is ok.but when i clicked... to verify that connection is correct or not.The testing has failed .so what could
About connection database oracle to java
About connection database oracle to java   I culdn't connect oracle datebase to java.when i compile the program it is ok. but when i clicked on sql... that connection is correct or not. The testing has failed .so what could be TNS
Tutorials   
Java Spring Hibernate Struts Training I am Java programmer. Should I learn Java Script or Python? Delete multiple records with pagination by selecting checkboxes How to add one hour in php date? connection in php connection in php connection in php PHP magento how to make previous and next Button Display Data in php session written exam display database results question create a simple form Magento Strings in PHP Zend Framework Installation in xampp? How to prevent adding duplicate items to the shopping cart php problem maximum execution time of 30 seconds exceeded in php Call-time pass-by-reference has been removed in HTTP_POST_VARS is deprecated $_GET[] index is not defined Function mysql_db_query() is deprecated Function mysql_db_query() is deprecated Function split() is deprecated Fatal error: Call to undefined function session_register() in .php file php tag not working Error reporting in PHP Why are MySQL Routines and Views not used with PHP? How to add Click to copy function to my wordpres blog? connection of php to MySQL. loan calculator Datepicker not getting called through include function of php change url string integrate login in php Installation of wamp server Display PHP clock with user input date and time value in div from php, reloading form pre-populate form developing a system using php n mysql Configure apache Tomcat to work with Eclipse and PDT in php How to display a file for 24 hours? LOGIN ERROR LOGIN FAILED", $_SESSION['login fail']='0',}?> I GOT ERROR FOR MY PROJECT PHP Sending emails and insert into trable Tutorial college Student Admission System PLZ HELP ME. i need php code.

Ads

 
Advertisement null

Ads