1

I'm setting up a new web application, and i want to find out a way to insert a row from PHP in Greek language

I make the connection with MySQLi from PHP like this:

 $con = mysqli_connect("localhost", "root", "", "Mydb");  
    if (!$con)    {                                                   
    echo "Error: Unable to connect to MySQL.";
    exit;         }
    if($con){       echo "connected with db <br/>";     } 

next step is to enter some values to a table like this:

    if(isset($_POST['ok']))
    {   
        mysqli_query($con,"INSERT INTO products (product_name,product_delivery) VALUES ('$product_name','$delivey')");                                 
    }   }

if i names of values is in English it works perfectly. But if I'm trying to insert a value in Greek language,then the line of the Data Base table corresponding to this record shows me symbols

Sample picture of the error

Aegean
  • 9
  • 5

2 Answers2

0

try the following:

after you connect to the mysql, do this query to make sure that you are using UTF8:

    mysqli_query("SET NAMES 'utf8'");
    mysqli_query("SET CHARACTER SET 'utf8'");

if this does not help, try different encoding, like ISO-8859-1

Montassar Bouajina
  • 1,482
  • 1
  • 8
  • 20
0

There is a way to set other language character sets for MySQL as shown here. Hopefully that fixes the problem.