我在mysql中遇到select语句的问题,我有一个像两列一样的表:
cz - varchar(64) - utf8_general_ci
pl - varchar(64) - utf8_general_ci
值:
pl - kwota sumaryczna
cz - celkováčástka
当我在表格中输入částka时我找不到任何东西,但是当我输入castka时我会找到数据。
在我的代码中我应该改变什么来使这个工作用于捷克标志和带有波兰标志的单词?
在网页上我有代码:
<form method="post" action="dict.php?go" id="searchform">
<input type="text" name="name" pattern=".{0}|.{2,}" required title="Conajmniej 2 litery" class="keyboardInput" size="50">
<input type="submit" name="submit" value="Szukaj">
</form>
<br>
<?php
if(isset($_POST['submit'])){
if(isset($_GET['go'])){
if(preg_match("/^[ a-zA-Z]+/", $_POST['name'])){
$name=$_POST['name'];
//connect to the database
$db=mysql_connect ("host", "user", "pass") or die ('I cannot connect to the database because: ' . mysql_error());
//-select the database to use
$mydb=mysql_select_db("base");
mysql_query("SET character_set_results = 'utf8', character_set_client = 'utf8', character_set_connection = 'utf8', character_set_database = 'utf8', character_set_server = 'utf8'");
//-query the database table
$sql="SELECT pl, cz FROM slow WHERE pl LIKE '%" . $name . "%' or cz LIKE '%" . $name . "%'";
//-run the query against the mysql query function
$result=mysql_query($sql);`