The browser shows me "???" instead of UTF-8 characters. What is the cause and how can I fix it?
Here is the HTML file:
<HTML>
<title>Search Engine</title>
<form action='search.php' method='GET'>
<font face='sans-serif' size='5'>
<center>
My Search Engine.<br>
<input type='text' size='50' name='search'> <input type='submit' name='submit' value='Search'><br>
</center>
</font>
<center><a href='submiturl.php'>Submit a URL</a></center>
</form>
</HTML>
This is the search.php
:
<?php
//get data
$button = $_GET['submit'];
$search = $_GET['search'];
if (!$button)
echo "Please fill out the form";
else
{
if (strlen($search)<=2)
echo "The item you searched for was to small";
else
{
echo "You searched for <b>$search</b> <hr size='1'>";
//connect to database
mysql_connect('localhost','k_search','1234.');
mysql_select_db('k_search');
//explode search term
$search_exploded = explode(" ",$search);
foreach($search_exploded as $search_each)
{
//construct query
$x++;
if ($x==1)
$construct .= "keywords LIKE '%$search_each%'";
else
$construct .= " OR keywords LIKE '%$search_each%'";
}
//echo out construct
$construct = "SELECT * FROM searchengine WHERE $construct";
$run = mysql_query($construct);
$foundnum = mysql_num_rows($run);
if ($foundnum==0)
echo "No results found.";
else
{
echo "$foundnum results found.<p><hr size='1'>";
while ($runrows = mysql_fetch_assoc($run))
{
//get data
$title = $runrows['title'];
$desc = $runrows['description'];
$url = $runrows['url'];
echo "<b>$title</b><br>
$desc<br>
<a href='$url'>$url</a><p>";
}
}
}
}
?>
This is the submiturl.php
:
<HTML>
<title>Search Engine</title>
<form action='submiturl.php' method='POST'>
<font face='sans-serif' size='5'>
<center>
Please fill out all fields to submit your URL.<br><br></font>
URL:<br><input type='text' size='50' name='url' value='http://www.'><br><br>
Site Name:<br><input type='text' size='50' name='title'><br><br>
Description (max 200 characters):<br><input type='text' size='50' name='description' maxlength='200'><br><br>
Keywords:<br><input type='text' size='50' name='keywords'><br><br>
<input type='submit' name='submit' value='Submit URL'>
</form>
<br><a href='index.html'>Go Back</a>
</center>
</HTML>
<?php
$submit = $_POST['submit'];
$title = $_POST['title'];
$description = $_POST['description'];
$url = $_POST['url'];
$keywords = $_POST['keywords'];
$connect = mysql_connect("localhost","k_search","1234.");
mysql_select_db("k_search");
if (!$title||!$description||!$url||!$keywords)
{
die ("<center>Please fill in all fields.</center>");
}
else
if ($submit)
{
mysql_query("INSERT INTO searchengine VALUES('','$title','$description','$url','$keywords')");
echo "<center>Website Submitted!</center>";
}
else
echo "<center>Please fill in all fields.</center>";
?>