Warning: Undefined variable $kind in /home4/wgate/public_html/include/checkfunpdo.php on line 662

Warning: Undefined variable $vers in /home4/wgate/public_html/include/checkfunpdo.php on line 662

Warning: Undefined variable $kind in /home4/wgate/public_html/include/checkfunpdo.php on line 662

Warning: Undefined variable $vers in /home4/wgate/public_html/include/checkfunpdo.php on line 662
:::| 目前位置圖示目前位置:首頁圖示回首頁 | 主功能頁圖示相關問答
mysql 無法存入 [金風]

[日期]:2025/08/27  [瀏覽人數]:285

[金風]需要使用utf8mb4才能正確存入MYSQL資料庫,

需要做一些更改才能正常存入

1.PHP PDO連接資料庫時設定

$link1->exec("SET NAMES utf8mb4");
$link1->exec("SET CHARACTER_SET_CLIENT=utf8mb4"); 
$link1->exec("SET CHARACTER_SET_RESULTS=utf8mb4");
$link1->exec("SET CHARACTER_SET_DATABASE=utf8mb4");
$link1->exec("SET CHARACTER_SET_SERVER=utf8mb4");
 
2.資料庫的資料表,更改欄位為utf8mb4_unicode_ci;
 
若以上未能設定正確在存檔時將會出現:
Invalid datetime format: 1366 Incorrect string value: '\xF0\xA9\x97\xA9\xE6\x98...' for column