php向mysql中插入utf8格式的中文报错!

2025-05-17 12:37:39
推荐回答(4个)
回答(1):

$res = odbc_exec($conn, 'set names utf8');
放在插入语句前
不行就把sql打印出来,手动复制到mysql控制台执行,看有什么错

回答(2):

在执行sql之前,设置字符编码

$res = odbc_exec($conn, 'set names utf8');
$res = odbc_exec($conn, $str_sql);

回答(3):

你编辑器的编码是utf8吗?

回答(4):

set names utf8