mysql query doesn't work correctly in php on server unlike xampp server
I am working on a Persian site with utf8_persian_ci collation.
my PHP code :
<?php
header('Content-Type: text/html; charset=utf-8');
$dbhandle = mysql_connect($hostname, $username, $password)
or die("Unable to connect to MySQL");
mysql_query("SET NAMES 'utf8'");
mysql_query("SET character_set_connection='utf8'", $dbhandle);
$selected = mysql_select_db("news",$dbhandle);
$str = 'ÝæÊÈÇá';
echo $str . '<br>';
$query = "SELECT * FROM news WHERE link_num='92051810161'";
$result = mysql_query($query);
if (mysql_num_rows($result) == 1) {
while ($row = mysql_fetch_array($result)) {
$from_db = $row{'category'};
echo $from_db . '<br>';
}
}
if ($str == $from_db) {
echo "string";
}
?>
the problem is that the last condition of code works in XAMP server and
prints string but when I run this code on Server the result is so
different!
Result on xamp server ( localhost ) :
ÝæÊÈÇá¡ ÝæÊÓÇá
ÝæÊÈÇá¡ ÝæÊÓÇá
string
Result on Server :
ÝæÊÈÇá
ÝæÊÈÇá
Also strpos() doesn't work on server but it works correctly in localhost!
I think the result of query on server is different with Xamp server on
localhost, but I can't find the result.
No comments:
Post a Comment