0

I deployed my PHP project, and when I open its link it shows a Server connection not possible. error.

I sure about the username, password, and database name

Config code file

<?php 
$db=new DB("wpaps_w2015","localhost","wpaps_dbuser","@beqwwqsT;67l");
?>

And this is the db.class.php file related to the DB connection :: Constructor

function DB($base, $server, $user, $pass)
{
  error_reporting(0);
  $this->mtStart    = $this->getMicroTime();
  $this->nbQueries  = 0;
  $this->lastResult = NULL;
  mysqli_connect($server, $user, $pass) or die('Server connecion not possible.');
  mysqli_select_db($base) or die('Server connecion not possible.');
}

This is the site link

I need someone to help me to understand what is wrong with the project, or to solve this error manually

  • https://www.php.net/manual/en/mysqli.error.php – Markus Zeller Aug 27 '22 at 12:37
  • Warning: mysqli_connect(): Server sent charset (255) unknown to the client. Please, report to the developers in /home/wpaps/public_html/ar/includes/db.class.php on line 34 – Ahmad Almabhoh Aug 27 '22 at 12:43
  • Warning: mysqli_connect(): (HY000/2054): Server sent charset unknown to the client. Please, report to the developers in /home/wpaps/public_html/ar/includes/db.class.php on line 34 Server connecion not possible. – Ahmad Almabhoh Aug 27 '22 at 12:43
  • These two error appear when I display errors, – Ahmad Almabhoh Aug 27 '22 at 12:44
  • I'm on production, I don't know how to change the charset on the server! Do you know how ?! – Ahmad Almabhoh Aug 27 '22 at 12:45
  • Does this answer your question? [SQLSTATE\[HY000\] \[2054\] Server sent charset unknown to the client. Please, report to the developers](https://stackoverflow.com/questions/53002483/sqlstatehy000-2054-server-sent-charset-unknown-to-the-client-please-report) – Markus Zeller Aug 27 '22 at 12:45
  • Okay. How I can change the charset on the server on production ?! – Ahmad Almabhoh Aug 27 '22 at 12:48

1 Answers1

0

check your php version,PHP 7.1 fails to connect to MySQL 8.0.x because of charset incompatibility with MySQL 8.0's new default server charset of utf8mb4.the workaround is to change the server charset back to pre-MySQL 8.0 default of utf8.enter link description here

such as:

function DB($base, $server, $user, $pass)
{
  error_reporting(0);
  $this->mtStart    = $this->getMicroTime();
  $this->nbQueries  = 0;
  $this->lastResult = NULL;
  $con = mysqli_connect($server, $user, $pass) or die('Server connecion not possible.');
  // Modify the database connection character set to utf8
  mysqli_set_charset($con,"utf8");
  mysqli_select_db($base) or die('Server connecion not possible.');
}
RorinL
  • 84
  • 8