从php中插入数据库中的特殊字符

I have a joomla database, where the mySQL connection collation is utf8_general_ci. I have some additional datatables in the database (not related to the joomla installation) that I want to populate with data from a PHP script.

LATER EDIT: check below

When I try inserting special characters (language and region specific characters) I get jibberish in the database, like îăîșț instead of îăîșț.

The collation for all the columns in the joomla database is : utf8mb4_unicode_ci (if this makes any difference)

The weird thing is, that if I show the content of the database in an email / mobile app (browser based) it shows the data correctly. But I can see, that something is not right with inserting the valus from PHP, since if I insert it manually from the phpmyadmin panel, the value will be correctly displayed in the table.

<?php header('Content-type: text/html; charset=UTF-8');  //header is specified here

$value_to_insert = addslashes($_REQUEST['value']);   //get the value from the parameter

inserttask($value_to_insert); //insert the value into the datatable

function inserttask($value_to_insert)
{
    $con = mysqli_connect("host",username,password,database); //set up my mysqli connection
    //mysql_set_charset('utf8'); //this didn't help

    if (!$con)
    {
        die();
    }

    $sql = "INSERT INTO `table` (`value`) VALUES ('".mysqli_real_escape_string($con, $value_to_insert)."')";

    if($result=mysqli_query($con,$sql))
    {
        print "OK";
    }
    else
    {
        print "ERROR";
    }
}

?>

Any ideas how this insert should be made, to make it compatible with any region dependend character?

Later edit: I ran the "show variables like '%collation%'" collation_connection - utf8_general_ci collation_database - latin1_swedish_ci collation_server - latin1_swedish_ci

Could this be the problem?

After setting up the connection as I had to change the connections charset in a specific way.

$con = mysqli_connect("mydb12.surf-town.net","bosteen_licadm","Ugymate92","bosteen_p2p");

$con->set_charset("utf8");

After this, the insert works!