mraza Posted March 24, 2011 Share Posted March 24, 2011 hi i know eval is not best way to run php code via database but its required to me. What is happening i am reading a feed and if i use eval it just repeat same rss links but if i put a direct code it show proper feed. here is my code which works proper $xml = simplexml_load_file($feedurl); foreach ($xml->channel->item as $item) { echo $item->title . "\n"; echo $item->link . "\n"; } results of above code are fine. Feed one title feed one link feed two title feed two link feed three title feed three link and so on for 10 times as 10 feeds are available...... But if i use eval my database contains <?php echo $item->title . "\n"; echo $item->link . "\n"; ?> and i run it like this $xml = simplexml_load_file($feedurl); foreach ($xml->channel->item as $item) { eval('?>' . $fromadatabase['code'] . '<?php '); } and i get this results Feed one title feed one link Feed one title feed one link Feed one title feed one link and so on...... means it just repeat first feed for 10 times Thanks for any help. Link to comment https://forums.phpfreaks.com/topic/231587-using-eval-with-feed-not-working/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.