我在显示带有特殊字符的数据时出错。我想显示这个词“C'har”然后发生 mysql_fetch_array() 错误。
这是我的完整代码:
<?php
header('Content-Type:text/html; charset=UTF-8');
$con = mysql_connect("localhost","root","") or die ("Cannot Connect to Server");
mysql_select_db("sarangani",$con) or die ("Cannot Connect to database");
$result = mysql_query("SELECT * from fes_category");
echo "<form method=\"post\" id=\"selct\" name=\"selct\">";
while($row = mysql_fetch_array($result))
{
$new = "<input type=\"submit\" id=\"ss\" name=\"ss\" value='".htmlspecialchars($row['fes_name'], ENT_QUOTES)."' class=\"ss\">";
echo $new;
}
echo "<input type=\"text\" name=\"subs\" id=\"subs\">";
echo "<input type=\"submit\" name=\"sub\" id=\"sub\">";
echo "</form>";
if(isset($_POST['ss']))
{
$sel = $_POST['ss'];
$results = mysql_query("SELECT fes_name from fes_category WHERE fes_name='".$sel."'");
$row = mysql_fetch_array($results);
if($sel == $row['fes_name'])
{
echo $sel;
}
}
?>