I am getting this code L' in the title of my mysql database. I can't figure out what I am doing wrong. I have tried several lines as you can see below but none seem to work.
The info is being abstracted from a website and placed in a database. However, all kinds of strange characters are being added as well as L'. How can I remove this and any other strange characters such as other encoding that does not belong?
I need the vars $t and $content to be safe to put into mysqli.
Here is a part of the code that would matter.
$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')");
}
}