php - insert variable to mysql database as utf-8 -


i have value in other language , want use utf-8 value.for use code store variable in database.

<?php $fname=$_post['fname']; $lname=$_post['lname']; $mysqli = new mysqli(host, user, password, database); $stmt=$mysqli->prepare("insert user (fname , lname) values (? , ? ) "); $stmt->bind_param("ss",$fname,$lname); $stmt->execute(); ?> 

i set collation fname , lname column utf-8.but not know how modify database connection insert variable utf-8.i set collation of user table utf-8.

try:

header("content-type: text/html; charset=utf-8"); // @ top of file  $mysqli->set_charset("utf8"); // before query 

set charset, header


Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -