0

你好stackoverflow的人!

我有一个问题,经过 3 个月的尝试,我无法解决。这个网站上描述了类似的问题,但他们没有给我我需要的结果。

我得到的结果: 删除链接

结构设置: 删除链接

我的编码:

include 'connectiondetails.php';

//making the database connection
dbVerbind();

$str = '<p>€ é í å </p>';

// things i've tried
//$test1 = $_GET['test1'];
//$test2 = htmlspecialchars_decode('<p>€ é í å </p>');
//$test3 = html_entity_decode($str, ENT_QUOTES, 'UTF-8');
//$test4 = htmlspecialchars_decode( $str , ENT_QUOTES);
//$test5 = htmlspecialchars('<p>€ é í å </p>', ENT_QUOTES);
//$test6 = parse_str(html_entity_decode($str), ENT_QUOTES);
//$orig = "<p>€ é í å </p>";
//$a = htmlentities($orig);
//$test7 = html_entity_decode($a);
//$test8 = $_GET['test8'];
//$test9 = htmlentities($str, ENT_QUOTES);
//$test10 = mysql_real_escape_string('€ é í å');

$test1 = $_GET['test1'];
$test2 = $_GET['test2'];
$test3 = $_GET['test3'];
$test4 = $_GET['test4'];
$test5 = $_GET['test5'];
$test6 = $_GET['test6'];
$test7 = $_GET['test7'];
$test8 = $_GET['test8'];
$test9 = $_GET['test9'];
$test10 = $_GET['test10'];

if (empty( $test1 )) {
echo '<p>empty</p>';
}
else {
$results =  mysql_query( "  INSERT INTO insert_test.content (   
                                            test1,
                                            test2,
                                            test3,
                                            test4,
                                            test5,
                                            test6,
                                            test7,
                                            test8,
                                            test9,
                                            test10
                                            )
                    VALUES(     '$test1',
                                '$test2',
                                '".htmlspecialchars('€ é í å')."',
                                '".mysql_real_escape_string('€ é í å')."',
                                '€ é í å',
                                '€ é í å',
                                '$test7',
                                '$test8',
                                '$test9',
                                '$test10'
                              )
                    " );
}
4

1 回答 1

1

您正在以 Unicode 格式发送字符,并且字段是 Unicode,但数据库连接不是。连接后立即使用:

SET NAMES 'utf8'
于 2012-06-18T16:02:18.203 回答