-3

Okay i am so mad at this i ve been working on this for like hours and it still doesn't work. it still gives me ?? when ii inserted some chinese characters on the table field.

I've already tried the below from stack overflow and it still doesn't work. i really need to get this finished or else i aint gonna know what to do with php functions on figuring out the position of a character if i use the form to insert code to the database because it gives me really random characters have no idea what they are.

The below are the methods i ve already approached:

Michelle
  • 1
  • 1
  • 1
    first to check, the input, is it properly chinese characters? next to check does your table's column is correctly supports chinese characters? is your charset correct? does the html override the charset? well, unless you gave us example on the code in question.. we can't exactly help you.. but giving more checklist items.. – Bagus Tesa May 03 '18 at 01:38
  • there's details missing. One of which is the api used to connect / query with is unknown and if you also gone through this one https://stackoverflow.com/questions/279170/utf-8-all-the-way-through - which stands to be a possible duplicate of here. – Funk Forty Niner May 03 '18 at 01:55
  • What's the encoding of your tables? – hungrykoala May 03 '18 at 02:11

1 Answers1

0

You've probably set the COLLATE for your SQL tables to utf8-unicode-ci. Don't worry about that right now, I suggest what you need to do is create a separate php file called connect.php or con.php or other such to put your connection/selection database stuff in there.

$username = "root";
$password = "";
$database = "databasename";
$server = "127.0.0.1";

$connect = @mysqli_connect($server, $username, $password);
$select = mysqli_select_db($connect, $database);

mysqli_set_charset($connect, 'utf8');

if(!$connect) { die("Connection failed: ".mysqli_error()); }
if(!$select) { die("Selection failed: ".mysqli_error()); }

Then put

require("connect.php");

on the top of all your php pages.

Once you've done so, you don't even need to worry about changing the Chinese code on the SQL statements you make.

YiJio
  • 49
  • 5