Randomly unable to connect to MySQL

Hello all,

I seem to be having a ‘randomly’ occurring problem. My current experiment in MouselabWEB is up and running and seems to be working fine. However, this is only most of the time. Sometimes, I get the following error:

“Error: Unable to connect to MySWL. Debugging errno: 1203”

This problem only occurs sometimes when I click on one of the forwarding links in the experiment, to go to the next page. When I go back to the previous page and then try to proceed to the next page using the same forwarding link, it usually suddenly works again. I realize it might not be a hosting issue, since no others (on InfinityFree) seem to be encountering this issue nor difficulties connecting to the server at the times I encounter this problem.

All pages are written in php and are usually able to forward to each other. Is there something I could change in my main script to solve this or could it be a hosting issue?

The script that could give this error follows below:


$DBhost = "sql304.epizy.com"; 		// hostname of the mySQL database 
$DBuser = "epiz_25505074"; 		// username of user on this database
$DBpass = "XXXXXXXX";		// user password (I blurred this on purpose)
$DBName = "epiz_25505074_MouselabWEB2";			// name of the database (I have 4 databases, so also 4 scripts like these)
$table = "mlweb";			// name of the table containing MLWEB Data (can be left to mlweb)

$link = mysqli_connect( 'p:'.$DBhost, $DBuser, $DBpass, $DBName);
if (!$link) {
    echo "Error: Unable to connect to MySQL." . PHP_EOL;
    echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL;
1 Like

i had the same issue Unable to conect to the database but this had a infinityfree issue and if you will disable all scripts site will work stable ? you can try to change php version at cpanel if script is disabled and you see the issue maybe its a infinity free issue or i dont know. :confused:

For starters, I would recommend to log or print the error message. Like the “message” part suggests, they convey information about the error, which a few digits don’t.

Googling the error code 1203 tells me that your website is running into the max_user_connections limit. That means your account has more than 5 database connections open at the same time. If you try to open a 6th connection, it will be refused with this error.

1 Like

That, unfortunately, is the entire error message…

Thank you for the tip. I already found that and tried finding a solution. However, the solution seems to be closing my connections. I do “close” the connections in my script (see below):

$sqlquery = "INSERT INTO $table (id, expname, subject, ip, condnum, choice, submitted, procdata, addvar, adddata) VALUES ($id,'$expname','$subject','$ipstr', $condnum,'$choice',NOW(),'$procdata', '$addvar', '$adddata')";
$result = mysqli_query($link, $sqlquery);

/* Redirect to a different page in the current directory that was requested */
$host  = $_SERVER['HTTP_HOST'];
$uri   = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
header("Location: http://$host$uri/$nextURL?subject=$subject&condnum=$condnum");

These are the only scripts running on my site at the moment… I tried changing the php version, but it didn’t help unfortunately.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.