I have the code below to try 5 times to connect to mysql:
mysqli_report(MYSQLI_REPORT_STRICT);
$NUM_OF_ATTEMPTS = 5;
$attempts = 0;
do {
try {
$mysqli = new mysqli("localhost", "root", "", "data");
break;
}
catch (Exception $e) {
echo mysqli_connect_error();
unset($mysqli);
$attempts=$attempts+1;
sleep(2);
if($attempts<$NUM_OF_ATTEMPTS){
continue;
}
else{
exit;
}
}
break;
}while($attempts < $NUM_OF_ATTEMPTS);
what happens is, if for example, in the first try some error occur and it connects in the second the CSS will show different. the inputs smaller and things like that. What is wrong?