Jump to content

problem with mysql_query("SET NAMES utf8");


zohab

Recommended Posts

hi all

 

i am trying to insert japanese data into mysql table but with the following insert query it insert some

garbage value into the database.

 

 

$details1='あのサン自動車工業製';

$details2='あのサン自動車工業製';

 

mysql_query("SET NAMES utf8");

 

$sql = "update products_description set commodity_details1='$commodity_details1' and  commodity_details2='$commodity_details2' where products_id=8";

echo"<br>".$sql;

$result = mysql_query($sql);

mysql_free_result($result);

 

 

-------------------------------------------------------------------------------------------------

 

with following code when i am trying to display japanese text from database it displays some garbage values

even i enter correct text into database it displays garbage value.

 

$conn = mysql_connect("host", "login","password");

 

if (!$conn) {

    echo "Unable to connect to DB: " . mysql_error();

    exit;

}

   

if (!mysql_select_db("database")) {

    echo "Unable to select mydbname: " . mysql_error();

    exit;

}

mysql_query("SET NAMES utf8");

//mysql_query("SET CHARACTER SET utf8");

 

$sql = "select * from products_description where products_id=8";

$result = mysql_query($sql);

 

//echo"<br>".$num_rows = mysql_num_rows($result);

 

while ($row = mysql_fetch_assoc($result))

{

    echo $row["commodity_details1"];

    echo $row["commodity_details2"];

 

}

 

any ideas?

 

thanks in advance

zohab

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.