php – 如何用外语选择mysql查询?
作者:互联网
让我以简单的方式向您展示
SELECT * FROM dictionary WHERE malayalam = 'ആകാശം'
这个查询在phpmysql上运行正常,同时它在.php页面上查询时没有检测到raw
我正在建立一个英语到马拉雅拉姆语和马拉雅拉姆语到英语词典
该网站是http://www.chatfitness.com/
接收来自mysql的malayalam单词在英文单词的基础上正常工作.
不幸的是,收到英文单词不能正常工作:(
我对这两个函数使用相同的查询
这是用英文单词搜索的代码
if(isset($_GET['en']))
{
$english = $_GET['en'];
mysql_query ("set character_set_results='utf8'");
$result=mysql_query("SELECT * FROM en_table WHERE word = '$english' LIMIT 1");
$numrows=mysql_num_rows($result);
if($numrows!=0){
$row = mysql_fetch_array($result);
$english_id = $row['en_id'];
//select malayalam id which are matching with english id
$en_query = mysql_query("SELECT * FROM dictionary WHERE english = '$english_id'");
//$en_rows = mysql_fetch_array($en_query);
while($en_rows = mysql_fetch_array($en_query)){
$en_malayalam = $en_rows['malayalam'];
mysql_query ("set character_set_results='utf8'");
$ml_query=mysql_query("SELECT * FROM ml_table WHERE ml_id = '$en_malayalam'");
while($ml_rows = mysql_fetch_array($ml_query)){
echo $ml_rows['word'];
echo "<br />";
}
}
}else{
echo "<p>നിങ്ങള് അന്വേഷിക്കുന്ന " . $english . " എന്ന പദത്തിന്റെ അര്ഥം കണ്ടെത്താനായില്ല.</p>
<p>സാധ്യമെങ്കില്, ദയവായി നിഘണ്ടുവില് ചേര്ക്കുക.</p>";
}
就像我在马拉雅拉姆搜索一样
}elseif(isset($_GET['ml'])){
$malayalam = $_GET['ml'];
mysql_query ("set character_set_results='utf8'");
$results=mysql_query("SELECT * FROM ml_table WHERE 'word'= '$malayalam' LIMIT 1");
$numrow=mysql_num_rows($results);
echo $numrow ;
//here is the problem $numrow always zero :(
if($numrow!=0){
$row = mysql_fetch_array($results);
$malayalam_id = $row['ml_id'];
//echo $malayalam_id ;
//select malayalam id which are matching with english id
$ml_query = mysql_query("SELECT * FROM dictionary WHERE malayalam = '$malayalam_id'");
//$en_rows = mysql_fetch_array($en_query);
while($ml_rows = mysql_fetch_array($ml_query)){
$ml_english = $ml_rows['malayalam'];
$ml_query=mysql_query("SELECT * FROM en_table WHERE en_id = '$ml_english'");
while($ml_rows = mysql_fetch_array($ml_query)){
//echo $ml_rows['word'];
echo "<br />";
}
}
}else{
echo "We do not have meaning of $malayalam at the moment. <br /> Could you add your word pls";
}
}else{
die("please select search value");
}
从mysql $numrow = mysql_num_rows($results)中搜索的内容; numrows总是为零:(
你可以帮我解决这个问题
我被困在这里:(
提前致谢
解决方法:
你应该尝试其中一个:
1.)使用mysql_set_charset(‘utf8’,$dbconn);而不是如http://php.net/manual/en/function.mysql-set-charset.php所示的mysql_query()
2.)使用query(“set names utf8”);正如SET NAMES utf8 in MySQL?所建议的那样
标签:mysql-error-1064,php,sql,mysql,phpmyadmin 来源: https://codeday.me/bug/20190926/1819597.html