Zac*_*ack 6 php mysql sql mysqli
"×"符号(不是一点点x),我相信这是乘法符号,正在打破MySQL记录.
问题是每当我尝试检索具有此符号"×"的记录时,记录将返回空白.
我顺便使用PHP和WAMP服务器.
整理是latin1_swedish_ci.但是,更改排序规则似乎并未解决问题.mysql版本是5.6.17这是我的函数,它从表中获取记录并将其保存到对象:
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++;
}
}
}
Run Code Online (Sandbox Code Playgroud)
这适用于没有"×"符号的任何东西.我不知道为什么该符号应该导致整个记录返回为空白.
我看到你使用 htmlspecialchars 直到 PHP 5.4 内部编码是 UTF-8。因此,如果您有一条包含 iso 数据的记录并将其放入htmlspecialchars中,则不会得到任何结果。
在这种情况下,您必须将编码设置为iso-8859-1。
为了解决这个问题,你可以定义一个编码
htmlspecialchars($value, ENT_QUOTES, "ISO-8859-1");
这将修复错误显示的符号:
mb_convert_encoding($value, "UTF-8");
我想这可能是你的问题。