General Error(!)

This is a discussion on "General Error(!)" within the Databases section. This forum, and the thread "General Error(!) are both part of the Program Your Website category.


 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Program Your Website > Databases

Notices




Reply
 
LinkBack Thread Tools
  #1  
Old Aug 20th, 2007, 19:52
Daniel's Avatar
Elite Veteran
Join Date: Sep 2006
Location: The Kingdom of Rabbits
Age: 21
Posts: 2,051
Blog Entries: 12
Thanks: 0
Thanked 0 Times in 0 Posts
General Error(!)

PHP: Select all

Return to index page 

General Error
SQL ERROR 
mysql4 ]

Too many connections [1040]

An sql error occurred while fetching this pagePlease contact an administrator if this problem persists
How do I counter this?
Last Blog Entry: Assassin's Creed (Nov 22nd, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
Old Aug 20th, 2007, 21:27
Reputable Member
Join Date: Jun 2007
Location: uk
Posts: 459
Thanks: 0
Thanked 0 Times in 0 Posts
Re: General Error(!)

You could try checking the number of connections allowed in my.ini
you should see a section of text like this

HTML: Select all
# The maximum amount of concurrent sessions the MySQL server will
# allow. One of these connections will be reserved for a user with
# SUPER privileges to allow the administrator to login even if the
# connection limit has been reached.
max_connections=100
set max connections to 500 or whatever.

This may not cure it but give it a try
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old Aug 20th, 2007, 21:40
Highly Reputable Member
Join Date: Apr 2007
Location: Willich, Germany
Age: 20
Posts: 593
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: General Error(!)

Quote:
Originally Posted by DanDoughty View Post
PHP: Select all

Too many connections [1040
Well, I think the error is obvious.

There are too many connections to the databank at once. There are a few things you can do about it:

1. Make sure you only leave databank connections open as long as you need them
PHP: Select all

$connection mysql_connect("localhost""root""") or die ("Could not connect!");
mysql_select_db("db_name"$connection) or die ("Database not found!"); 
do stuff and as soon as you are done:
PHP: Select all

mysql_close($connection); 


2. The second thing you can do is having proper error handling. This doesn't solve your problem but at least you can catch errors and output a nice friendly error message (i.e.: "Server overloaded. Please try again in a few seconds") to the user.
Check all your databank queries for errors like so:
PHP: Select all

if(mysql_query("INSERT INTO table_name (text) VALUES ('some text')")) {
  echo(
"success");
} else {
  echo(
"error");

or like so:
PHP: Select all

$query=mysql_query("SELECT * FROM ".$table_name." ORDER BY date DESC");
if(
$row=mysql_fetch_object($query)) {
  
// do something
} else {
  echo(
"error");

Hope that helps....
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4  
Old Aug 20th, 2007, 22:07
Daniel's Avatar
Elite Veteran
Join Date: Sep 2006
Location: The Kingdom of Rabbits
Age: 21
Posts: 2,051
Blog Entries: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Re: General Error(!)

And in English?
Last Blog Entry: Assassin's Creed (Nov 22nd, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5  
Old Aug 20th, 2007, 22:23
Highly Reputable Member
Join Date: Apr 2007
Location: Willich, Germany
Age: 20
Posts: 593
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: General Error(!)

OK, which part do you need translated?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6  
Old Aug 20th, 2007, 23:26
Daniel's Avatar
Elite Veteran
Join Date: Sep 2006
Location: The Kingdom of Rabbits
Age: 21
Posts: 2,051
Blog Entries: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Re: General Error(!)

As I don't know one end of MySQL from the other - er.. Everything?
Last Blog Entry: Assassin's Creed (Nov 22nd, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #7  
Old Aug 21st, 2007, 08:13
Highly Reputable Member
Join Date: Apr 2007
Location: Willich, Germany
Age: 20
Posts: 593
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: General Error(!)

OK, I'm not sure if I understand everything good enough to give a proper explanation, but I'll give it a shot

1. mySQL connections.
PHP: Select all

$connection mysql_connect("localhost""root""") or die ("Could not connect!"); 

In this line you are storing a mysql_connection resource in the $connection variable. The first parameter is the server name, the second is your username and the third, your password. The 'or die' part catches any errors that could occur while trying to connect to the server (for example: the server is down, or your username and/or password is wrong). The 'die' means that PHP execution stops right there and the page outputs the error. I'd guess that this is the place where you are getting your error.
PHP: Select all

 mysql_select_db("db_name"$connection) or die ("Database not found!"); 

Here we select the database that we are going to be reading from. The first parameter is the database name and the second is the mysql_connection resource that we generated in the line above. Again, you can see the 'or die' to catch possible errors.

2. Error handling (catching errors and dealing with them yourself instead of the user getting a cryptic message).
PHP: Select all

if(mysql_query("INSERT INTO table_name (text) VALUES ('some text')")) {
  echo(
"success");
} else {
  echo(
"error");

I think you would know how an IF statement works.... The mysql_query function sends a query to the currently-opened database and returns a resource. However, when the query fails, it returns false, and that is the kind of thing that you can catch and deal with yourself.
PHP: Select all

$query=mysql_query("SELECT * FROM table_name");
if(
$row=mysql_fetch_object($query)) {
  
// do something
} else {
  echo(
"error");

This is similar to the previous example, only that we store the returned resource into a variable and check if that operation was a success.

3. Closing the connection.
PHP: Select all

mysql_close($connection); 

This is the important part. The mysql_close function takes a connection resource as parameter and tells the database that we are done and closes the connection. This means that there is now one more connection available for use. Most database queries only take a few milliseconds, so an error like this only rarely occurs, and if you refresh the page a couple seconds later, the problem will already be solved.

OK, I hope that clarifies a few things.
That was my good deed for the day....
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #8  
Old Aug 21st, 2007, 09:40
Daniel's Avatar
Elite Veteran
Join Date: Sep 2006
Location: The Kingdom of Rabbits
Age: 21
Posts: 2,051
Blog Entries: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Re: General Error(!)

Did I mention the site is a forum?
Last Blog Entry: Assassin's Creed (Nov 22nd, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #9  
Old Aug 21st, 2007, 09:57
Reputable Member
Join Date: Jun 2007
Location: uk
Posts: 459
Thanks: 0
Thanked 0 Times in 0 Posts
Re: General Error(!)

what are your max connections settings with your host. Could it have just been a glitch at there end.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
error

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
General Mac Problems gribble Webforumz Cafe 29 Aug 29th, 2007 22:31
Keep getting error message Microsoft VBScript runtime error '800a01a8' cpando1974 Classic ASP 2 Aug 7th, 2007 12:00
General Help needed davor2000 Web Page Design 4 Jun 12th, 2007 15:03
graphics in general ivyholly Graphics and 3D 5 Oct 5th, 2005 11:55


All times are GMT. The time now is 00:23.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42