I need some help here, so i have this file: ▄█████▄ ░█████▄ ▄████▄░█▄ ░█▄ ▄█████▄ ███▄██ ▄██ ▄█▄ ▄██████ ▄█▄ ▄███ ░████░██▀████▓ ▀██ ▄██░▀█████ ████ ███▓ ██████▓██ ▓███████ ███▓░▀█▀████ ███▓ ███▓ ▓███░ ██ ██▄ ▄██▓██ ▓███▓██░ ▓███░███░███████████▄ ███░███░ ███░ ▄███ ███ ▄█▀░ ████████░██ █████████▄ ▓██░███ ███▓█████████ ███████ ███ ███░ ███████ ███▓ ░██ ██ ██████▓ ░██ ▀██ ███░███▓██████ ███▓███ ███ ███ ████████░███░ ███ ██▄ ██▓███░ ██▄ ██░██▓ ███ ▀▀████ ███░███ ███ ███ ███▓░███████░ ███ ███▓██ ███ ███▓██▓██░ ███ ▓████ ███ ███ ▓██▓ ███ ███░ ▓██████ ███ ▓████ ▓██▄ ▓████████ ███ ▓███ ███ ███ ███░███ ███ ░██████ ███ ░████ ░███ ███▓███▓ ███ ░███ ███ ███ ██▓███ ███ ███▓██ ███ ███ ▓██▄ ███░███░ ███ ███ ███ ███ ░█████ ███ ██▓░██▄ ███ ▓█▀ ▓██▄ ███ ██░ ███ ██▓ ███ ███ ░███▀ ░█▀ ██░ ██ ░█▀ ░███▄ ▀ ▀ ▓█▀ ███░ ░█▀ ██▀ ██░ ▄██▀ ░█▄ ▄███▀ ░██ ░ ██ ▓░ ▓░ ██░ ▓█░ ░█▀ ▀█░ ░█▓ Code (markup): now i want to insert it to mysql table and than export it with php, how can i do this? i managed to insert it to table exactly how it looks in the code tag but when i try to show it from table with php i see only strange simbols, can anyone help me?
Well. The trick is you have to use the same character encoding every time. In the first place, MYSQL varchar fields have a character encoding. MySQL connection has a character encoding and Apache issues HTML specifying character encoding in HTTP field. MySQL connection: bool mysql_set_charset ( string $charset [, resource $link_identifier ] ) Apache configuration or .htaccess: AddDefaultCharset <charset> In example: PHP mysql_connection(...); mysql_set_charset('utf-8'); Code (markup): .htaccess AddDefaultCharset UTF-8 Code (markup):
thanks for your answer, i added mysql_set_charset('utf-8'); my table is utf8_unicode_ci i am on localhost so i can't add htaccess i managed to do something here but the problem is that when i output the code from table it show all code only to one line not on multi lines how it should be Edit: if i output the code in a textarea it show fine
Are you running PHP from command line? Please copy the portion of PHP which is actually outputting the text. Use PHP tags in advanced mode when posting the code!
Oh yeah, sorry, didn't read the last post completely. Sounds like you just need to add nl2br($text) ?
db conn: $conn=mysql_connect($dbhost, $dbuser, $dbpass); mysql_query("SET character_set_results = 'utf-8', character_set_client = 'utf-8', character_set_connection = 'utf-8', character_set_database = 'utf-8', character_set_server = 'utf-8'", $conn); PHP: insert to db: <form name="form" action="" method="get" id="form" onsubmit="return false"> <label>info</label><br /><textarea name="info" cols="60" rows="5"></textarea><br /> </form> $info=$_POST['info']; mysql_query("insert into data (info) VALUES ('$info') ") or die(mysql_error()); PHP: output: $query=mysql_query("select * from data where id = '$id'"); $row = mysql_fetch_array($query); echo $row['info']; PHP: this is what i get: ▄█████▄ ░█████▄ ▄████▄░█▄ ░█▄ ▄█████▄ ███▄██ ▄██ ▄█▄ ▄██████ ▄█▄ ▄███ ░████░██▀████▓ ▀██ ▄██░▀█████ ████ ███▓ ██████▓██ ▓███████ ███▓░▀█▀████ ███▓ ███▓ ▓███░ ██ ██▄ ▄██▓██ ▓███▓██░ ▓███░███░███████████▄ ███░███░ ███░ ▄███ ███ ▄█▀░ ████████░██ █████████▄ ▓██░███ ███▓█████████ ███████ ███ ███░ ███████ ███▓ ░██ ██ ██████▓ ░██ ▀██ ███░███▓██████ ███▓███ ███ ███ ████████░███░ ███ ██▄ ██▓███░ ██▄ ██░██▓ ███ ▀▀████ ███░███ ███ ███ ███▓░███████░ ███ ███▓██ ███ ███▓██▓██░ ███ ▓████ ███ ███ ▓██▓ ███ ███░ ▓██████ ███ ▓████ ▓██▄ ▓████████ ███ ▓███ ███ ███ ███░███ ███ ░██████ ███ ░████ ░███ ███▓███▓ ███ ░███ ███ ███ ██▓███ ███ ███▓██ ███ ███ ▓██▄ ███░███░ ███ ███ ███ ███ ░█████ ███ ██▓░██▄ ███ ▓█▀ ▓██▄ ███ ██░ ███ ██▓ ███ ███ ░███▀ ░█▀ ██░ ██ ░█▀ ░███▄ ▀ ▀ ▓█▀ ███░ ░█▀ ██▀ ██░ ▄██▀ ░█▄ ▄███▀ ░██ ░ ██ ▓░ ▓░ ██░ ▓█░ ░█▀ ▀█░ ░█▓ Code (markup): and this if i add nl2br: ▄█████▄ ░█████▄ ▄████▄░█▄ ░█▄ ▄█████▄ ███▄██ ▄██ ▄█▄ ▄██████ ▄█▄ ▄███ ░████░██▀████▓ ▀██ ▄██░▀█████ ████ ███▓ ██████▓██ ▓███████ ███▓░▀█▀████ ███▓ ███▓ ▓███░ ██ ██▄ ▄██▓██ ▓███▓██░ ▓███░███░███████████▄ ███░███░ ███░ ▄███ ███ ▄█▀░ ████████░██ █████████▄ ▓██░███ ███▓█████████ ███████ ███ ███░ ███████ ███▓ ░██ ██ ██████▓ ░██ ▀██ ███░███▓██████ ███▓███ ███ ███ ████████░███░ ███ ██▄ ██▓███░ ██▄ ██░██▓ ███ ▀▀████ ███░███ ███ ███ ███▓░███████░ ███ ███▓██ ███ ███▓██▓██░ ███ ▓████ ███ ███ ▓██▓ ███ ███░ ▓██████ ███ ▓████ ▓██▄ ▓████████ ███ ▓███ ███ ███ ███░███ ███ ░██████ ███ ░████ ░███ ███▓███▓ ███ ░███ ███ ███ ██▓███ ███ ███▓██ ███ ███ ▓██▄ ███░███░ ███ ███ ███ ███ ░█████ ███ ██▓░██▄ ███ ▓█▀ ▓██▄ ███ ██░ ███ ██▓ ███ ███ ░███▀ ░█▀ ██░ ██ ░█▀ ░███▄ ▀ ▀ ▓█▀ ███░ ░█▀ ██▀ ██░ ▄██▀ ░█▄ ▄███▀ ░██ ░ ██ ▓░ ▓░ ██░ ▓█░ ░█▀ ▀█░ ░█▓ Code (markup):
Well. HTML collapses leading whitespaces unless you use PRE tag. Try encolsing the output inside <pre></pre> <? $query=mysql_query("select * from data where id = '$id'"); ?> <pre> <? while($row = mysql_fetch_array($query)) { echo $row['info']; } ?> </pre> PHP: