Doubt with collation of mysql

0

I am putting together a part of the page where I will show brief "news" that will be loaded by the administrators of the page. I am using the MySQL database and I have some doubts about the "collation" and the possibility that I can save the complete data: accents, "ñ", etc ...

At the moment I have it set in latin1_swedish_ci.

One of the questions I have is if I put a textarea to write the note and then save the data, how does what I put in the database behave? Do you keep the line breaks?

    
asked by MNibor 01.07.2017 в 00:42
source

1 answer

1

I tell everyone that It is not a good practice to manage  information like: á images, etc, never do it, for that there is the UTF-8, and they can implement it in the following way:

  

WEB (HTML) --- > CLIENT

  

MYSQL --- > DATABASE

And in the database the information would be recorded in this way

This is the right thing, I hope I have helped you, regards.

  

PHPMYADMIN

If you use PDO for database connections, you can use this statement to send the utf8 content to the database.

$con = new PDO('mysql:host=' . $server . ';dbname=' . $db . ';charset=UTF8', $user, $pass, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
    
answered by 01.07.2017 / 09:13
source