Hi, I created function, but im getting error: (PHP Fatal error: Call to undefined function rss1() in C:\phptest\test9.php on line 17) Here is my code <?php // Fetch the file data try { $con = new PDO("sqlsrv:Server=hadi-tosh;Database=rssfeed", "rssuser", "rssuser"); $con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"); rss1("http://www.albaldnews.com/rss.php?cat=24","اخبارالبلد"); function rss1($url,$source) { $rss = simplexml_load_file($url); if($rss) { $items = $rss->channel->item; foreach($items as $item) { $title = $item->title; $link = $item->link; $published_on = $item->pubDate; $description = $item->description; $category = $item->category; $enclosure = $item->enclosure[0]['url']; $img2 = $item->enclosure[0]['url']; $ch = curl_init ($enclosure); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_BINARYTRANSFER,1); $rawdata=curl_exec ($ch); curl_close ($ch); $query = $con->prepare("SELECT COUNT(*) FROM [feedtable] where title =:title and link=:link and pubdata=:pubdata and description=:description and category=:category and image=:image and imagelink=:imagelink and source=:source "); $query->bindParam(':title', $item->title); $query->bindParam(':link', $item->link); $query->bindParam(':pubdata', $item->pubDate); $query->bindParam(':description', $item->description); $query->bindParam(':category', $item->category); $query->bindParam(':image', $rawdata, PDO::PARAM_LOB, 0, PDO::SQLSRV_ENCODING_BINARY); $query->bindParam(':imagelink', $img2); $query->bindParam(':source', $source); $query->execute(); $num_rows = $query->fetchColumn(); if($num_rows == 0) { $stmt = $con->prepare('insert into [feedtable] (title,link,pubdata,description,category,image,imagelink,source) values (:title,:link,:pubdata,:description,:category,:image,:imagelink,:source)'); $stmt->bindParam(':title',$item->title); $stmt->bindParam(':link',$item->link); $stmt->bindParam(':pubdata',$item->pubDate); $stmt->bindParam(':description',$item->description); $stmt->bindParam(':category',$item->category); $stmt->bindParam(':image', $rawdata, PDO::PARAM_LOB, 0, PDO::SQLSRV_ENCODING_BINARY); $stmt->bindParam(':imagelink',$img2); $stmt->bindParam(':source',$source); $stmt->execute(); echo "albaldnews feeds added\n"; } else { echo "albaldnews duplicate entry\n"; } } } } } catch (PDOException $e) { exit("Connection failed: " . $e->getMessage()); } ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php