php - when i insert of description and img_url data behave differently?
PHP
$rss = new SimpleXMLElement($xml, LIBXML_NOCDATA);
foreach ($rss->channel->item as $item) {
foreach ($rss->channel->item as $item) {
$guid = $item->guid ;
$title = $item->title ;
$url = $item->link;
$description = (string)$item->description ;
$date = $item->pubDate;
$img_url = $item->enclosure['url'] ;
$category = $item->category[1] ;
Insert($guid,$title,$description,$url,$date,$img_url) ;
}
function Insert($g,$t,$des,$u,$d,$imgu) {
global $connection ;
echo $g,"<br>",$t,"<br>",$des,"<br>",$u,"<br>",$d,"<br>",$imgu,"<br>" ;
$insert_sql = "INSERT INTO rssfeed (guid,title,description,url,date,img_url) VALUES (?,?,?,?,?,?)" ;
$stmt = $connection->stmt_init() ;
$stmt->prepare($insert_sql) ;
$stmt->bind_param('isssss',$g,$t,$des,$u,$d,$imgu);
$stmt->execute() ;
}
when i echo in function it shows clear output but in database in description and img_url and url coulmns have different data entry .both urls haven't full url information which as show in output file .
second question how can i sanitize the all this before input my db like dates ,url and tittle etc.
both images of output and database