feri_soft Posted February 21, 2007 Share Posted February 21, 2007 I am not pretty sure if its a php4 and 5 compatibility problem or safe mode issue, safe mode is off both on the php5 and php4. The exact version is php 4.4.4 Here is what looks like the source. Its not the rss reader problem but i supose something between the while and foreach as all the database and rss stuff works well when removed from the foreach cycle: <?php define('MAGPIE_DIR', 'rss/'); require_once(MAGPIE_DIR.'rss_fetch.inc'); require_once('db.php'); $q = mysql_query("getting cats and feeds"); if(!$q) die(mysql_error()); while($row = mysql_fetch_array($q, MYSQL_ASSOC)) { $url = $row['rss']; $category = $row['catname']; if (!empty($url)) { $rss = fetch_rss( $url ); foreach ($rss->items as $item) { $link = $item['link']; $title = mysql_real_escape_string($item['title']); $keywords = str_replace(" ", ",", addslashes($title)); $description = mysql_real_escape_string(strip_tags($item['description'])); $ip = $_SERVER['REMOTE_ADDR']; $q2 = mysql_query("SELECT * FROM `articles` where title = '$title'"); $err = mysql_num_rows($q2); if($err == 0){ $query = "some inserts"; mysql_query($query) or die(mysql_error()); } } } } ?> Please give me a suggestion on how to rewrite this while still keeping the functionality but have both php4 and php5 support. Thanks! Link to comment https://forums.phpfreaks.com/topic/39507-php-5-code-to-php-4/ Share on other sites More sharing options...
Ninjakreborn Posted February 21, 2007 Share Posted February 21, 2007 Looking over just the code you presented there, there doesn't seem to be any issues related to the PHP verrsion. It should fully support 4 and 5. What other things have you tried, why did you originally come to the conclusion it was just the php version that was causing the problem? Link to comment https://forums.phpfreaks.com/topic/39507-php-5-code-to-php-4/#findComment-190653 Share on other sites More sharing options...
feri_soft Posted February 21, 2007 Author Share Posted February 21, 2007 Because i dont see anything else in except the php version which might cause the problem as safe mod is off on both of the servers and pear is supported on both too and when i try the code on the php5 server is ideal but on the php 4 server doesnt do anything that is in the foreach contruction. IF i put anything out of the foreach for exаmple between the while and foreach like echo $category; its printed. So any suggestions. I need this really much. Link to comment https://forums.phpfreaks.com/topic/39507-php-5-code-to-php-4/#findComment-190691 Share on other sites More sharing options...
Jessica Posted February 21, 2007 Share Posted February 21, 2007 $rss = fetch_rss( $url ); What does fetch_rss do? PHP 4 & 5 handling of objects did change, so it could cause problems. Link to comment https://forums.phpfreaks.com/topic/39507-php-5-code-to-php-4/#findComment-190694 Share on other sites More sharing options...
obsidian Posted February 21, 2007 Share Posted February 21, 2007 $rss = fetch_rss( $url ); What does fetch_rss do? PHP 4 & 5 handling of objects did change, so it could cause problems. Looks like he's using Magpie RSS reader, which returns an object with that function call. Magpie is compatible with PHP 4.3.2, so that shouldn't be your issue. Link to comment https://forums.phpfreaks.com/topic/39507-php-5-code-to-php-4/#findComment-190717 Share on other sites More sharing options...
feri_soft Posted February 22, 2007 Author Share Posted February 22, 2007 Well, what is then?? I realy need a sugestion to help sort that out. Link to comment https://forums.phpfreaks.com/topic/39507-php-5-code-to-php-4/#findComment-191332 Share on other sites More sharing options...
redarrow Posted February 22, 2007 Share Posted February 22, 2007 post all you varables trust. $_POST['']; Link to comment https://forums.phpfreaks.com/topic/39507-php-5-code-to-php-4/#findComment-191339 Share on other sites More sharing options...
obsidian Posted February 22, 2007 Share Posted February 22, 2007 Well, what is then?? I realy need a sugestion to help sort that out. Did your MySQL version change? That could cause a problem as well. Link to comment https://forums.phpfreaks.com/topic/39507-php-5-code-to-php-4/#findComment-191364 Share on other sites More sharing options...
feri_soft Posted February 22, 2007 Author Share Posted February 22, 2007 I dont use anything with postthis will be a script to be run as a cron for updating some rss and adding info in db. And for the database suggestion i dont quite think its the database as when i remove queries or actually move them outsite the foreach they work ideal. But yes database versions are different. Link to comment https://forums.phpfreaks.com/topic/39507-php-5-code-to-php-4/#findComment-191447 Share on other sites More sharing options...
feri_soft Posted February 22, 2007 Author Share Posted February 22, 2007 i have now found that safe mode was ON. I really dont see what can cause this confusion but in the phpinfo() its set to off...hoever from the host support they are telling me its on so i am pretty sure thats the reason. Is there a way of doing the same functionallity without having to turn of the safe mode?? Link to comment https://forums.phpfreaks.com/topic/39507-php-5-code-to-php-4/#findComment-191578 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.