php在URL中传递中文参数,插入到mysql乱码问题
我需要在url中直接带sql语句,插入到数据库,
http://localhost/insert.php?s=insert+into+members+(uid,username)+values+(null,'蓝色')
这样插入的是乱码,中文变成了 %C0%B6%C9%AB ,英文和数字一切正常。请问如何解决,谢谢
<?php
include("conn.php");
$s=urlencode($_GET['s']);
$s = str_replace('+','%20',$s);
$s = str_replace('%2C',',',$s);
$s = str_replace('%27','\'',$s);
$s = str_replace('%28','(',$s);
$s = str_replace('%29',')',$s);
$s = str_replace('%20',' ',$s);
$s = str_replace('%5C','',$s);
$SQL="$s";
$query=mysql_query($SQL);
$err=mysql_error();
if($err){
echo "error:".mysql_error();
}else{
echo "success";
}
mysql_close($conn);
?>