简体   繁体   中英

Character Encoding issue in PHP and HTML

In database I have stored some ID's the values are something like "A001" OR "A-001". The value is perfectly stored in database but when I display them in browser it gets converted into numeric value 2.

How can I display the exact string on browser. I have tried with echo, print and var_dump()

If you can provide more information for replication, you would get good answers. I doubt I understood your question. Assuming database is MySQL, this code should work:

<?php
    mysql_connect(YOUR_HOST,YOUR_ID,YOUR_PW);
    $result = mysql_fetch_array(mysql_query("select ID from YOUR_TABLE where ID='A001'");
    echo $result[0];  // A001 would be shown in browser
?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM