The "Γ—" character violates MySQL records

The symbol "Γ—" (not a little x), I believe that it is a symbol of multiplication, violates MySQL records.

The problem is that whenever I try to get a record that has this β€œΓ—β€ character, the record is returned as empty.

I am using a PHP server and WAMP, by the way.

The mapping is latin1_swedish_ci. However, changing the collage did not help solve the problem. Mysql version is 5.6.17 Here is my function that gets records from a table and saves it for an object:

public function assign() { $SQL = "SELECT * FROM " . $this->tb . " ORDER BY " . $this->order; $this->tb_handle = mysqli_query($this->db_handle,$SQL); $this->rowNumber = mysqli_num_rows($this->tb_handle); //this creates arrays from records given even if the table is empty //this is to prevent errors if ($this->rowNumber === 0) { foreach ($this->records as $record) { $this->{$record} = array(); } } else { $i = 0; while ( $db_field = mysqli_fetch_assoc($this->tb_handle) ) { foreach ($this->records as $record) { $this->{$record}[$i] = $db_field[$record]; $this->{$record}[$i] = htmlspecialchars($this->{$record}[$i]); } $i++; } } } 

This works for anything that does not have the β€œΓ—β€ character. I don’t know why this symbol should cause the whole record to return as empty.

+6
source share
1 answer

I see that you use htmlspecialchars before PHP 5.4, the internal encoding of UTF-8. Therefore, if you have a record with iso data and you put it in htmlspecialchars , you will not get the result.

In this case, you need to set the encoding iso-8859-1 .

To solve the problem, you can define the encoding

htmlspecialchars($value, ENT_QUOTES, "ISO-8859-1");

This will cause the characters to display incorrectly:

mb_convert_encoding($value, "UTF-8");

I think this may be your problem.

+3
source

Source: https://habr.com/ru/post/974198/


All Articles