Hello stackoverflow人员!
我遇到了一个问题,经过3个月的尝试,我无法解决这个问题。这个网站上描述了类似的问题,但他们没有给我我需要的结果。
我得到的结果: click here for the result i get
结构设置: click here for the structure
我的编码:
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'
)
" );
}
答案 0 :(得分:1)
您要将字符作为Unicode发送,并且字段是Unicode,但数据库连接不是。连接后立即使用:
SET NAMES 'utf8'