The PDO connection to the database does not work

The PDO connection to the database does not work.

My code on the site:

   $hn      = 'localhost';
   $un      = secret';
   $pwd     = 'secret"';
   $db      = secret';
   $cs      = 'utf8';
	
	$dsn  = "mysql:host=" . $hn . ";port=3306;dbname=" . $db . ";charset=" . $cs;
	$opt  = array(
                        PDO::ATTR_ERRMODE            => PDO::ERRMODE_EXCEPTION,
                        PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ,
                        PDO::ATTR_EMULATE_PREPARES   => false,
                       );
	$pdo  = new PDO($dsn, $un, $pwd, $opt);

Error

<br />
<b>Fatal error</b>:  Uncaught PDOException: SQLSTATE[HY000] [1045] ProxySQL Error: Access denied for user secret'@'2a02:4780:bad:f00d::12' (using password: YES) in /storage/ssd3/224/3573224/public_html/mobileapp/loginUser.php:15
Stack trace:
#0 /storage/ssd3/224/3573224/public_html/mobileapp/loginUser.php(15): PDO-&gt;__construct('mysql:host=loca...', 'id3573224_sport...', 'secret&quot;', Array)
#1 {main}
  thrown in <b>/storage/ssd3/224/3573224/public_html/mobileapp/loginUser.php</b> on line <b>15</b><br />

Input data is correct!

Is secret the actual value you are using?

Of course not.
Why should I post my login and password on the forum?

Okay, the error says that you are using a wrong database username or password

The tooth I give, that I correctly enter. Maybe there is a problem in the port?

Can you change your db’s password and try again?

I solved the problem. I apologize. The quote hid in the password: D

1 Like