Search code examples
mysqlsshubuntu-16.04lamp

Inserting special characters to mysql database


I am building a basic web application which searches through a mysql database using a simple php script to retrieve results based on a few checkboxes on the page, everything is working except the database handling.

The problem seems to be happening when i try to fill my database, i have a few thousand entries but here's a single example.
The input:
INSERT INTO example_database.test_table (testcolumn) values ("LÆRER");
Seems to run without a problem, but when i try to select all items from the table it gets returned without the "Æ" character
In console i get;>"LRER", In the web browser the character is presented as �, "L�RER"
I have tried altering both the database and table specifically for UTF-8 with no luck.
NOTE: The lowercase equivalent "æ" DOES work.
I am running a LAMP stack on Ubuntu 16.04.
mysql -V and php -v;

mysql  Ver 14.14 Distrib 5.7.30, for Linux (x86_64) using  EditLine wrapper
PHP 7.0.33-0ubuntu0.16.04.14 (cli) ( NTS )

EDIT:
I have come to a diagnosis of sorts, after "opening" or entering mysql> the console stops recognizing the character upon input, at least it doesn't display anything as having been input. Still no idea how to fix it though.


Solution

  • Ended up figuring it out, it was an issue with the MySQL "shell"(?)/client not accepting the characters. I ended up making a separate page on my site with just a simple textbox input that I populated my tables with, after which everything worked fine. This isn't really a solution to the actual problem, but more of a workaround.