skip to Main Content

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

2

Answers


  1. 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

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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search