Reputation: 83
So my website is currently exploding right now.
In my header.php (logged in users only have) checks if there is an mysql_error.
If one is found, it destroys the session and outputs:
Sorry, something went wrong
mysql_error
]
Other Notes
There is a Session Variable that is created when the user logs in, and the value is the user's id (auto_increment) in the database. When header.php is trying to find the ID in the database from $_SESSION['id']
, it (very rarely) pops up with "Sorry, something went wrong", then the mysql_error()
.
The code that outputs this error is
$fetchuser = "SELECT * FROM `duavatar_db`.`users` WHERE `users`.`id`=".$_SESSION['id'];
$exec = mysql_query($fetchuser, $con);
if(mysql_num_rows($exec) == 0){
session_destroy();
die("Sorry, something went wrong.<hr>".mysql_error());
}
YES, $con IS A DEFINED VARIABLE. duavatar_dba is the mysql account username.
Upvotes: 2
Views: 2691
Reputation: 2176
That's a MySQL setting which limits the number of connections that a single user can have to the database at any one time. Your PHP application generally connects to the database using a single user account - For example The one you use in the statement:
mysqli_connect("localhost","THIS_USER","my_password","my_db");
You're traffic is obviously exceeding the number of allowed connections.
Increase the value using these instructions:
http://dev.mysql.com/doc/refman/5.7/en/user-resources.html
For example, if you want to increase the maximum number of connections to 20:
ALTER USER 'your_user'@'your_host' WITH MAX_USER_CONNECTIONS 20;
Don't accidently reduce the number though. Check the current value using this query:
SELECT * FROM mysql.user;
Upvotes: 1