fael097 Posted April 1, 2011 Share Posted April 1, 2011 hi, I'm making a website, in portuguese, and i'm trying to retrieve characters with accent signals such as é ê á etc. while when I directly type words with such characters directly in my HTML, it displays correctly (i'm using utf-, if i save the same words into a mysql DB, and echo them out with php, they will appear with missing characters, you know, the "?" inside a square. im clueless. any help is appreciated. thanks in advance Link to comment https://forums.phpfreaks.com/topic/232439-reading-db-info-special-chars/ Share on other sites More sharing options...
fael097 Posted April 1, 2011 Author Share Posted April 1, 2011 I made a simple test for debugging, heres my code: (I typed "ácéntôão" e "tôrrãodeaçúcar" directly on html for testing, those are exactly the same words I've put on my database.) <?php session_start(); $host_db="localhost"; $name_db="test"; $login_db="root"; $pass_db="123456"; $conn_db=mysql_connect($host_db, $login_db, $pass_db)or die("Could not connect. ".mysql_error()); $select_db=mysql_select_db($name_db, $conn_db)or die("Could not select database. ".mysql_error()); ?> <!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Untitled Document</title> </head> <body> ácéntôão<br /> tôrrãodeaçúcar<br /> <?php $sql="SELECT * FROM test ORDER BY id LIMIT 3"; $result=mysql_query($sql); if(mysql_num_rows($result)) { while($row=mysql_fetch_row($result)) { echo $row[1]."<br />"; } } ?> </body> </html> my result: ácéntôão tôrrãodeaçúcar �c�nt��o t�rr�odea��car words in HTML appear exactly as I typed them, but the ones coming from DB appear with those unknown characters. what to do? i tried everything Link to comment https://forums.phpfreaks.com/topic/232439-reading-db-info-special-chars/#findComment-1195682 Share on other sites More sharing options...
fenway Posted April 3, 2011 Share Posted April 3, 2011 Then your PHP headers aren't correct. Link to comment https://forums.phpfreaks.com/topic/232439-reading-db-info-special-chars/#findComment-1196253 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.