Warning: mysql_connect(): Too many connections in dbconnect

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
hifake
Forum Newbie
Posts: 1
Joined: Mon May 29, 2006 12:12 am

Warning: mysql_connect(): Too many connections in dbconnect

Post by hifake »

twigletmac | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


I have a dbconnect.php file.
This is the code i have in that

Code: Select all

<?PHP
	function exec_query($sql)
	{
		$server = "localhost";
		$username = "root";
		$pwd = "Pass";
		$db_name = "test";
		$link = mysql_connect($server,$username,$pwd) or die ("Check Servername, User, Password");
		mysql_select_db($db_name) or die ("Check Databasename");
		$result=mysql_query($sql) or die ("Check Query");
		mysql_close($link);
		return $result;
	}
?>
In my code, i call it like this

Code: Select all

<?PHP
	require 'dbconnect.php';
	$tmpsql = "Select distinct code from tbl_emp";
	$result=exec_query($tmpsql);
	while($row=mysql_fetch_array($result))
	{
		//my code
	}
?>
After few hours of running this, i recieved this error

Warning: mysql_connect(): Too many connections in dbconnect.php on line 8
Check Servername, User, Password


someone help me out of this :(


twigletmac | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

It means that your mysql server doesn't accept any more connections. You'll have to contact your database adminstrator and ask him to change the number of allowed connections.
Post Reply