我将运行一个圣经网站,因此我使用 MYSQL 默认字符集 latin1_swedish_ci 创建了数据库,但该网站将使用西类牙语。
问题是创世记使用重音符号,Éxodo 和 Josué 也是,所以当人们搜索例如:
$getbook = $_GET['L'];
$bible = mysqli_query($database, "SELECT * FROM `bible` WHERE `book` LIKE '%$getbook%'");
如果人们搜索不带口音的 Genesis,则会有结果,但如果人们搜索带口音的 Génesis,则不会有任何结果。
这是我显示结果的脚本:
<?php
$server = 'localhost';$user = 'username';$pass = 'password';$source = 'this';
$database = @mysqli_connect ($server, $user, $pass, $source) OR die ('Could not connect to MySQL: ' . mysqli_connect_error());
header ('Content-type: text/html; charset=iso-8859-15');
$getbook = $_GET['L'];
$bible = mysqli_query($database, "SELECT * FROM `bible` WHERE `book` LIKE '%$getbook%'");
while($show = mysqli_fetch_assoc($bible)) {
?>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-15">
<table width="80%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="10%">Chapter</td>
<td width="10%">Verse</td>
<td width="80%">Text</td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
<table width="80%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="10%"><?php echo $show['chapter'] ?></td>
<td width="10%"><?php echo $show['verse'] ?></td>
<td width="80%"><?php echo $show['text'] ?></td>
</tr>
</table>
<?php
}
?>
结果文本还可以,唯一的问题是当您使用重音符号进行搜索时。它显示 Genesis 的结果,但不显示带重音的 Génesis 的结果。
这是要测试的真实站点:
WITH ACCENT:
http://santabiblia.cl/?L=Génesis
no results
WITHOUT ACCENT:
http://santabiblia.cl/?L=Genesis
Yes we have results
有什么想法吗?
编辑
数据库看起来像
数据库名称 圣经 -> 书 - 章 - 节 - 正文
例子
book = Génesis(带口音)chapter = 1 verse = 1 = text = In the beginning God created the heaven and the earth(但用西类牙语)En el principio, Dios creó los cielos y la tierra。
MYSQL结构在latin1_swedish_ci,用latin1_spanish_ci测试,同样问题,用UTF8测试,差
最佳答案
您需要修改提交 L
的脚本并对其进行 URL 编码,同时接收脚本 URL 对其进行解码。
关于php - 在 MYSQL 中搜索具有西类牙口音的圣经网站字符集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30352967/