我正在尝试构建一个注册系统并将用户名和密码存储在数据库中
我用 PHP 编写了代码,但我在 PDO 中遇到错误,并且找不到解决方案 错误:
Uncaught Error: Undefined class constant 'ERRMODE_EXPECTION' in /storage/ssd4/295/11285295/public_html/config.php:8 Stack trace: #0 /storage/ssd4/295/11285295/public_html/index.php(2): require_once() #1 {main} thrown in /storage/ssd4/295/11285295/public_html/config.php on line 8
我的代码:
<?php
$db_user = "id11285295_useraccounts";
$db_password = "(my password here)";
$db_name = "id11285295_useraccounts";
$db = new PDO('mysql:host=localhost;db_name=' . $db_name . ';charset=utf8', $db_user, $db_password);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXPECTION);
此外,我还有另一个注册页面需要此功能
最佳答案
第一个错误行表示问题出在指定的字符集上。 utf8-unicode-ci
是字符集utf8
下的排序规则,而不是字符集。
参见documentation关于字符集。
关于php - Uncaught Error : Undefined class constant 'ERRMODE_EXPECTION' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58474611/