Again problem with script when i use cyrillic letters. I have simple php script witch gathers data from form, sets that in mysql db, and displays that data on the web page. The script is the simpliest as it can be. Im new in php programming so i watch many tuts, so to set story short, its simple script. It works ok when i use latin letters. BUT. When i use the same script (which obviously works) for inputs in cyrillic letters it shows error on "mysql_fetch_error"!? I red many coments about similar problem on internet, and theres no simple answer. Collation is ok, i tried with utf8-unicode, utf8-general and utf8-bin, again nothing.
<?php
if(isset($_POST['submit'])){
$con=mysql_connect('x','x','x');
if(!$con){
die("Cant connect:".mysql_error());
}
mysql_query('SET NAMES "UTF8"');
mysql_select_db("x",$con);
$ins = sprintf('INSERT INTO x (`Име_и_презиме`,`Датум_рођења`,`Занимање`,`Град`,`Земља`,`Имејл`,`Скајп`) VALUES
("%s", "%s", "%s", "%s", "%s", "%s", "%s")',
mysql_real_escape_string($_POST['ime']),
mysql_real_escape_string($_POST['datum']),
mysql_real_escape_string($_POST['zanimanje']),
mysql_real_escape_string($_POST['grad']),
mysql_real_escape_string($_POST['zemlja']),
mysql_real_escape_string($_POST['email']),
mysql_real_escape_string($_POST['skype'])
);
mysql_query($ins,$con);
mysql_close($con);
}
?>
<?php
$con=mysql_connect('x','x','x');
if (!$con){
die("Cant connect:" . mysql_error());
}
mysql_query('SET NAMES "UTF8"');
mysql_select_db ("x",$con);
$sql="SELECT * FROM x";
$myData=mysql_query($sql,$con);
echo "<table border=1>
<tr>
<td>Име и презиме</td>
<td>Датум рођења</td>
<td>Занимање</td>
<td>Град</td>
<td>Земља</td>
<td>Email</td>
<td>Skype</td>
</tr>";
while($record=mysql_fetch_assoc($myData)){
echo "<tr>";
echo "<td>" . htmlspecialchars($record['Име_и_презиме']) . "</td>";
echo "<td>" . htmlspecialchars($record['Датум_рођења']) . "</td>";
echo "<td>" . htmlspecialchars($record['Занимање']) . "</td>";
echo "<td>" . htmlspecialchars($record['Град']) . "</td>";
echo "<td>" . htmlspecialchars($record['Земља']) . "</td>";
echo "<td>" . htmlspecialchars($record['Имејл']) . "</td>";
echo "<td>" . htmlspecialchars($record['Скајп']) . "</td>";
echo "</tr>";}
echo "</table>";
mysql_close($con);
?>
ERROR: Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/xyz/public_html/form.php on line 46