我是网络编程的新手,所以如果我说错了,我深表歉意。我正在编写一个简单的 php 脚本来搜索阿拉伯语 mysql 数据库(来自本网站http://qurandatabase.org/Database.aspx - mysql 查询文件格式 - 阿拉伯语(原始)的古兰经数据库),但我有一个非常简单的问题,这是我在我的 php 脚本中通过 GET 方法收到的不是我输入搜索的内容,并且在我的搜索字符串中添加了一些不需要的阿拉伯字符。我的代码和输出如下:我的 html 代码是:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="ar" xml:lang="ar">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<body>
<form action="p.php" method="get" accept-charset="UTF-8">
Word Search: <input type="text" name="word"/>
<input type="submit"/>
</form>
</body>
</html>
我的PHP代码是:
<?php
header('Content-type: text/html; charset=utf-8');
$DBServer="localhost";
$DBUser="root";
$DBPass="1";
$DB="Quran";
$DBTable="Quran";
//echo "Welcome".$_GET["fname"];
$Word=$_GET['word'];
echo $Word;
echo "<br />";
echo "<br />";
$con=mysql_connect($DBServer,$DBUser,$DBPass);
if(!$con)
{
die("DB Connection error: ".mysql_error());
}
mysql_select_db($DB,$con);
echo "<br />\n";
echo "<br />\n";
echo "<br />\n";
echo "<br />\n";
echo "select * from $DBTable where AyahText like '%".$Word."%'";
echo "<br />\n";
$select="select * from $DBTable where AyahText like '%ﻢِﻧَ ﺎﻠْﺠِﻧَّﺓِ ﻭَﺎﻠﻧَّﺎﺳِ%'";
echo $select;
echo "<br />\n";
echo "<br />\n";
$select="select * from $DBTable where AyahText like '%".urldecode($Word)."%'";
echo $select;
echo "<br />";
$result=mysql_query($select);
//$result=mysql_query("select * from $DBTable where VerseID=$Word");
$LastSura=1;
echo $LastSura;
echo "<br />";
while($row=mysql_fetch_array($result))
{
echo "salam";
echo $row['SuraID']."\t".$row['VerseID']."\t".$row['AyahText'];
echo "<br />";
if($row['SuraID']!=$LastSura)
{
echo "<br />";
echo "<br />";
}
$LastSura=$row['SuraID'];
}
mysql_close($con);
?>
我在我的 html 文本框中输入了这个字符串:
مِنَ الْجِنَّةِ وَالنَّاسِ
但我得到这个字符串,输出几乎没有差异,你必须自己测试它:
مِنَ الْجِنَّةِ وَالنَّاسِ
select * from Quran where AyahText like '%مِنَ الْجِنَّةِ وَالنَّاسِ%'
select * from Quran where AyahText like '%مِنَ الْجِنَّةِ وَالنَّاسِ%'
select * from Quran where AyahText like '%مِنَ الْجِنَّةِ وَالنَّاسِ%' 1
它导致我的搜索失败。
我不知道这个用于提问的复制和粘贴是否让我的正确输出正确显示给你,但在我的浏览器中 الْجِنَّةِ 和 النَّاسِ 在 ن 我的输出中有不需要的 ِ 或 َ。非常感谢您的帮助。