Jump to content

php 5 code to php 4


feri_soft

Recommended Posts

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.