这让我兴奋。
mb_detect_order("UTF-8");
$str_firstName = ucwords(strtolower(trim($str_firstName)));
$str_encoding = mb_detect_encoding($str_firstName);
$str_firstName = mb_convert_encoding($str_firstName, "UTF-8", mb_detect_encoding($str_firstName));
$str_sql="SELECT * FROM db6901371_clients.costCentreClients cCC WHERE isDeleted = 0 AND cCC.firstName = '$str_firstName'";
echo "<br>str_sql= ".$str_sql."</br>";//works when cut and pasted into phoMyAdmin
$res = $mysqli->query($str_sql) or die("Line ".__LINE__.$mysqli->error);
$res->num_rows;
$res->data_seek(0);
$row = $res->fetch_assoc();
if ($res->num_rows>0) {
//firstName exists
}
从文本文件中读入 $str_firstName
如果剪切并粘贴到phpMyAdmin中,$str_sql
将找到记录,但从php运行时则不会。
我在sql中尝试了LIKE,BINARY和各种COLLATE语句。
在文本文件中并且在db6901371_clients.costCentreClients中具有匹配项的30多个名称中,只返回1的匹配项。