Wednesday, 28 August 2013

Accented characters trouble in SQL

Accented characters trouble in SQL

Ok, I have a web where I consult a database (phpMyAdmin) and display some
results (it's basically a searcher). The problem comes when I display
results from this Database that have accented characters. The pages in the
web are codified in utf-8 and all the content of the web accept accented
characters except when I call this database by php. I have also put the
collation of the database, the table and the fields on it in
ut8-general-ci. I have spent a lot of time finding a solution and it never
cames up. I leave the code (in php) when calling the information in the
Database:
... some code
//We select the webs with the same keywords (coincidences).
//We order first the search in the same language. All ordered by Title.
$result = mysql_query("SELECT * FROM Webs WHERE Keywords LIKE '%$search%'
ORDER BY CASE WHEN Language='English' THEN 0 ELSE 1 END, Title", $link);
if ($row = mysql_fetch_array($result))
{
//We start the list of results
echo "<ul>";
do
{
//One list element
echo "<li>";
echo "<a
href=http://".$row["Url"].".html><b>".$row["Title"]."</b></a><br/>";
echo "<a href=http://".$row["Url"].".html>".$row["Url"]."</a><br/>";
echo "".$row["Description"]."<br/>";
echo "</li><br/>";
}
while ($row = mysql_fetch_array($result));
//We end the list of results
echo "</ul><br/>";
}
else
{
echo "<p>No register has been found !</p>";
}
?>
Please any help will be welcomed.

No comments:

Post a Comment