Client page:
<head>
<meta http-equiv="Catchup Scheduler" content="text/html; charset=UTF-8">
</head>
<body>
<form action="next.php" method="POST" >
<input type="text" name="programme_name"></br>
<input type="submit">
</form>
</body>
Server page:
$name = $_POST['programme_name'];
mysql_query("SET character_set_client=utf8",$con);
mysql_query("SET character_set_connection=utf8", $con);
mysql_query("SET character_set_results=utf8", $con);
$query = "Select * from programme where Programme_name Like '%".$name."'";
Problem is although there is Chinese text in the database, the query always returns ZERO(none)
. If I print the POST value $name
it displays the correct text with the Chinese characters.
but if i store it in a variable, such as:
$name= "valuevalue ( 官话 )";
$query = "Select * from programme where Programme_name Like '%".$name."'";
It produces results. How could this be, in POST it doesn't but static value declaration it does? My OS is XP SP3.
Is there a problem in the "internal" representation of Chinese characters if it is in POST? Do I need to set something in my OS to support Chinese representation?
You are feeding mySQL unescaped, raw input.
Use mysql_real_escape_string
on your input string or better yet use PDO to talk to the database.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.