I have a form that reads some data. And a php file that sends this data to the database. All of the html files and php file are UTF-8. When the form reads the data, I have a check with echo
right before the INSERT statement. The echo
displays the words correctly. But when it is sent to database, it arrives with broken characters.
For example:
I send the word "Būve
". echo
prints it exactly like that. But in the database I get "Būve
".
I have both of these right after connection as well.
mysql_query("SET NAMES UTF8");
mysql_query("SET CHARACTER SET utf8");
PHP code:
echo $_POST[pasutitajs];
$sql = "INSERT into ligumitable (nrpk, ligums, pasutitajs, parkstisanasdatums, summa,) VALUES ('$_POST[nrpk]', '$_POST[ligums]', '$_POST[pasutitajs]', '$_POST[parkstisanasdatums]', '$_POST[summa]')";
Tables in the database are utf8 as well, if I unput the data through phpmyadmin, using these characters, everything is fine. It's the INSERT that breaks it. What could be wrong?
EDIT:
This is funny. Thing is, i am not the only one working on the code. And now that I checked it, my buddy used "$conn->query($sql)" and not "mysql_query($sql)". No idea why. I changed it to a regular mysql_query and it works. Thanks everyone, sorry for bothering you with such a simple thing.