圣经网站charset与西班牙语口音搜索MYSQL

时间:2015-05-20 14:42:11

标签: php html mysql css character-encoding

我将运行一个圣经网站,所以我使用MYSQL默认字符集latin1_swedish_ci创建了数据库,但该网站将是西班牙语。

问题在于,Génesis一书使用了口音,Éxodo和Josué也是如此,所以当人们搜索例子时:

$getbook = $_GET['L'];
$bible = mysqli_query($database, "SELECT * FROM `bible` WHERE `book` LIKE '%$getbook%'");

如果人们在没有重音符号的情况下搜索创世记,那么就会有结果,但是如果人们搜索带有重音的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>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</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

有什么想法吗?

修改

数据库看起来像

DB_NAME 圣经 - &gt;书 - 章节 - 诗歌 - 文本

例如

book =Génesis(带口音)chapter = 1 verse = 1 = text =一开始上帝创造了天堂和地球(但是用西班牙语)En el principio,Dioscreóloscielos y la tierra。

MYSQL结构在latin1_swedish_ci中,用latin1_spanish_ci进行测试并且遇到同样的问题,用UTF8测试它更糟糕

1 个答案:

答案 0 :(得分:0)

您需要修改提交cc <- scales::seq_gradient_pal("blue", "red", "Lab")(seq(0,1,length.out=100)) 的脚本并对其进行URL编码,而接收脚本网址会对其进行解码。

相关问题