After a search here I couldn't see anyone with the same (strange) problem as me. I have a very simple task which is to check whether some name already exists on a table, but the thing is the mysql_num_rows is returning wrong values.
I'm sorry, I forgot to mention that this only happens when I try to look for words with special chars. Bebês, Câmeras, Calção
are examples.
$sql = "
SELECT cattitle as category
FROM categories
WHERE cattitle = '$title'
";
$res = mysql_query($sql, $con) or die(mysql_error());
$num = mysql_num_rows($res);
I even have tried with mysql_result
$sql = "
SELECT count(cattitle) as category
FROM categories
WHERE cattitle = '$title'
";
$res = mysql_query($sql, $con) or die(mysql_error());
$num = mysql_result($res,0);
The worst thing is, when I run the query directly, I get the correct results ($num > 0). I'm not that experienced programmer and, at first, I thought it was returning values from other queries, but I've checked and changed the name of those vars and the problem persisted.
Could be some kind of conflict? Can someone help me with this error? Kind regards,