User co_p already has more than 'max_user_connections' active connections

344
July 17, 2017, at 5:55 PM

I have a PHP Code to insert some information from a large text file in the beginning of the file i have this code:

<?php
$host = "localhost";
$username = "user";
$password = "pass";
$db = "dbname";
mysql_connect($host,$username,$password) or die(mysql_error());
mysql_select_db($db) or die(mysql_error());
mysql_close;
set_time_limit(0);
$fh = fopen("file.txt", "r");
while ($row = fgets($fh)) {
//// CODE ....
   mysql_query("INSERT IGNORE INTO `TABLE` VALUES (NULL, '$ETC', '$ETC', '$ETC')"); 
}
    fclose($fh);
?>

but after some iserts i got this error :

Warning: mysql_connect(): User co_p already has more than 'max_user_connections' active connections in /home/username/public_html/file.php on line 7 User co_p already has more than 'max_user_connections' active connections

any solution for this problem ?

  • I'm the OWNER of the SERVER !
Answer 1
mysql_close; 

should be generating an error.

This command should be

mysql_close();

Add error reporting to the top of your file(s) while testing right after your opening PHP tag for example <?php error_reporting(E_ALL); ini_set('display_errors', 1); to see if it yields anything.

But I have to ask, why are you connecting to the database and then closing the connection straight after?

After more code added.

As you are actually trying to access the database, you dont want to do a mysql_close(); where you have coded it.

But I have to add:

Every time you use the mysql_ database extension in new code this happens it is deprecated and has been for years and is gone for ever in PHP7. If you are just learning PHP, spend your energies learning the PDO or mysqli database extensions and prepared statements. Start here

Answer 2

Try to close mysql connection:

$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
....
mysql_close($link);
Rent Charter Buses Company
READ ALSO
Overlapping dates/times in parking reservations

Overlapping dates/times in parking reservations

I have a problem with MYSQL query to get the overlapping with reservations

230
which mysqli query need mysqli_connect

which mysqli query need mysqli_connect

Connection file is as below

288
MySQL : weekly and monthly SUM

MySQL : weekly and monthly SUM

The below given is my TOUR table:

271
MySQL use view to access table under different name

MySQL use view to access table under different name

I have a performance and best-practice question concerning mysql tablesIĀ“m working on an application which connects to a database which gets filled by other programms

218