Jump to content

Unicode data retrieve from mysql using php problem


Go to solution Solved by Jacques1,

Recommended Posts

I want to retrieve unicode based (Bengali language) data from mysql (wamp server 3 is running). I have inserted data using PhpMyAdmin and can read the font. but when I tried to read using php in html it just shows '?????' ! I know it is creating problem with unicode data. any solution?? how I can handle in PHP when I can read data from PhpMyAdmin ?

 

my code is: for lastest row only

PHP Code:

 

<?php

$connect = mysqli_connect("localhost", "root", "", "sumonn");

$sql=("SELECT * FROM `notice` ORDER BY id DESC limit 1" );

$result_set=mysqli_query($connect,$sql);

while($row=mysqli_fetch_array($result_set))

{

echo $row['notice'];

}

 

?>

 

 

Please help!

 

Jacques1 << thank you very much. it solved my problem! <meta charset="utf-8"> was there but your "mysqli::set_charset()" link solved my problem. I added my code and looks like bellow :happy-04: 
<?php
$connect = mysqli_connect("localhost", "root", "", "sumonn");
// this lines solved my problme, changing latin1 to utf8 after connction (start) 
if (!mysqli_set_charset($connect, "utf8")) {
    printf("Error loading character set utf8: %s\n", mysqli_error($connect));
    exit();
} else {
    printf("Current character set: %s\n", mysqli_character_set_name($connect));
} // this was the last line of my changed code   
	$sql=("SELECT * FROM `notice` ORDER BY id DESC limit 1" );
	$result_set=mysqli_query($connect,$sql);
	while($row=mysqli_fetch_array($result_set))
	{      
       echo $row['notice'];
	}
       
    if (!mysqli_set_charset($connect, "utf8")) {
    printf("Error loading character set utf8: %s\n", mysqli_error($connect));
    exit();
} else {
    printf("Current character set: %s\n", mysqli_character_set_name($connect));
}    
	
?>

Hope it will help others like mine. 

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.