我在mysql数据库的标题中得到了这个代码L&#39。我无法弄清楚我做错了什么。我已经尝试了几行,如下所示,但似乎都没有。
信息从网站中抽象出来并放在数据库中。然而,除了L&#39之外,还添加了各种奇怪的角色。如何删除这个以及任何其他奇怪的字符,例如不属于的其他编码?
我需要将vars $ t和$ content安全放入mysqli。
以下是重要的代码部分。
$con=mysqli_connect("myserver","yadayda","yadayda","yadayda");
// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
if (!$con->set_charset("utf8")) {
printf("Error loading character set utf8: %s\n", $con->error);
} else {
printf("Current character set: %s\n", $con->character_set_name());
}
for($i = 0; $i < 7; $i++)
{
$ID = date(U);
$t = $Title[$i];
$t = html_entity_decode(htmlentities($t,ENT_QUOTES),ENT_QUOTES);
//$content = htmlentities($content,ENT_QUOTES);
$result = mysqli_query($con,"SELECT * FROM myDatabase WHERE Title ='$t'");
$rowCount = mysqli_num_rows($result);
echo $rowCount;
if($rowCount == 0)
{
$content = mysqli_real_escape_string($con,$content);
$t = mysqli_real_escape_string($con,$t);
mysqli_query($con,"INSERT INTO myDatabase (ID, Content, Title,imageLink,theLink) VALUES ('$ID', '$content','$t','$imageLink','$theLink')");
}
}