I want to know why does this code work:
$conn = new PDO("mysql:host=localhost;dbname=university;charset=utf8","root","",
array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8'"));
while this one doesn't:
$conn = new PDO("mysql:host = localhost;dbname=university;charset = utf8","root","");
I have problem on that utf8
section. Second code showed me ??? as result but first one worked properly. Both should work properly but...
The difference are the spaces near the two "=".
You need to erase them.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.