PHP Fatal error: Out of memory

Hi!
I suddenly have this error on my site, without having made any changes to the code:

Firefox has detected that the server is redirecting the request for this address in a way that will never complete.

I first contacted my web host, but they gave no help.

In my error log, it tell me it’s an “out of memory” error in Common.php. The line # it gives contains:
[php]$tr.=substr($str,$nr2+1);[/php]

which is part of this function:

[php]function ReplacePA($str,$art)
{
if($nr1=strpos($str,’[’))
{
$tr=substr($str,0,$nr1);
$nr2=strpos($str,’]’,$nr1);
$tr.=$art[substr($str,$nr1+1,$nr2-$nr1-1)];
$tr.=substr($str,$nr2+1);
return ReplacePA($tr,$art);
}
else
{
$OUT = explode(“76PULL*PULL76”, $str);
return $OUT[1];
}
}[/php]

I have some php knowledge, but not enough to figure this out. Any ideas appreciated!

Do you know what the memory_limit value is set to? Is the ReplacePa function being called from within a loop?

Thanks for replying, Jakal! The memory limit was increased to 500M in attempt to solve the error, but it didn’t help. Nope, there’s not a loop.

I ended up replacing the function calls with a similar function I found in the code:
function ReplaceCA($str,$art)
{
if($nr1=strpos($str,’[’))
{
$tr=substr($str,0,$nr1);
$nr2=strpos($str,’]’,$nr1);
$repl = substr($str,$nr1+1,$nr2-$nr1-1);
$tr.=$art->$repl->Value;
$tr.=substr($str,$nr2+1);

    return ReplaceCA($tr,$art);
  }
  else
  {
    return $str;
  }

}

and this eliminated the error. Would you (or anyone else here) be able to tell me if this function does the same thing as the other, and what exactly are these functions replacing?

You might want to try lowering your memory_limit to 128 and see if there are no bad effects from that; 500m is a lot of memory per user. It’s difficult to say 100% what the functions will return without having looked at the datasets that are sent to the function. I would use the php function print_r($str) on the return value from each function to see what is being returned for comparison.

you can use:

echo ‘

’;
echo print_r($str);
echo ‘
’;

to make it more human readable. I hope that helps.

Sponsor our Newsletter | Privacy Policy | Terms of Service