你指的是: Warning: Unexpected character in input: ''' (ASCII=39) state=1 in D:\documentRoot\ad.php on line 8Warning: Unexpected character in input: '\' (ASCII=92) state=1 in D:\documentRoot\ad.php on line 8Warning: Unexpected character in input: ''' (ASCII=39) state=1 in D:\documentRoot\ad.php on line 8Notice: Use of undefined constant ?- assumed '? in D:\documentRoot\ad.php on line 8么?
Warning: Unexpected character in input: ''' (ASCII=39) state=1 in D:\documentRoot\ad.php on line 8Warning: Unexpected character in input: '\' (ASCII=92) state=1 in D:\documentRoot\ad.php on line 8Warning: Unexpected character in input: ''' (ASCII=39) state=1 in D:\documentRoot\ad.php on line 8Notice: Use of undefined constant ?- assumed '? in D:\documentRoot\ad.php on line 8么?
echo mysql_real_escape_string('上海');这二个你对比一下。
注意保证文件的编码和你set names设置的编码一致。
mysql_set_charset('utf8', $conn) or die('set charset failure.');
然后再显示就ok了,
echo '碶';
就要报错的
对于 GBK 编码
碶 的第二个字节的内码为 0x5c 正好是反斜杠“\”的内码。而他恰好出现在串尾,所以会出现问题。
这种包含特殊字符的汉字共有十几个
没有特别好的处理方法,你可以在处理时在串为加一个空格对于 utf-8 编码,就没有问题了
看看吧
mysql_query("set names gbk;")
mysql_query("set names gb2312;")