i have a mysql database that stores the arabic in it, it works fine in both savng the arabic characters and retrieving the content, the probem i am receiving is when i retrieve this arabic content from the database and want to use in another query it does not work:
//Database Connection
mysql_query("SET CHARACTER SET utf8");
$sql = mysql_query("SELECT * FROM `categories` WHERE 1");
while($row1 = mysql_fetch_array($sql))
{
$category = $row1['label_id']; //Arabic Content is retrieved displayed correctly
$query1 = mysql_query("SELECT * FROM `user_list` WHERE `Category` = '" .$category . "' ORDER BY `private_number` DESC");
$query1 = mysql_query("SET CHARACTER SET utf8");
while($row = mysql_fetch_array($query1))
{
//returns zero rows
}
}
but when i copy the string echo above and query without concatenating it does work very well example:
$query1 = mysql_query("SELECT * FROM `user_list` WHERE `Category` = 'الأفراد' ORDER BY `private_number` DESC");
What is wrong with my php code and what can i do to change it