开发者

Maximum execution time exceeded (PHP)

开发者 https://www.devze.com 2023-01-09 11:31 出处:网络
im getting this error, and i don\'t know why. Fatal error: Maximum execution time of 30 seconds exceeded in E:\\web\\autoopti\\thanks.php on line 65

im getting this error, and i don't know why.

Fatal error: Maximum execution time of 30 seconds exceeded in E:\web\autoopti\thanks.php on line 65

The code I have for the PHP script is:

<?php
    $key = 129;

    $email = $_REQUEST["payer_email"];
    $first = $_REQUEST["first_name"];
    $last = $_REQUEST["last_name"];
    $acode = $_REQUEST["hash"];

    $txt = $email . "|" . $email . "|" . $first . "|" . $last . "|" . $acode;
    $outtxt = '';

    for($i=开发者_StackOverflow社区0;$i<strlen($txt);)
    {
        for($j=o;$j<strlen($key);$j++,$i++)
        {
            $outtxt .= $txt{$i} ^ $key{$j};
        }
    }

    echo "thanks";
?>

And the line the error message refers to is:

$outtxt .= $txt{$i} ^ $key{$j};

So, I'm guessing it's just taking too long for this line of code to do its work. Can somebody please help me fix this?

Thank you


You have an infinite loop. $j starts at o (which is converted to 'o', since there is no o constant), rather than 0, and:

$j = 'o';
$j++;

results in $j = 'p' (even though 'o' + 1 is 1...)

It continues with $j eventually going from 'z' to 'aa'. Any non-numeric string is < any number, so the inner loop is infinite.

I'm not really sure what the point of the script is. But it looks like you're trying to do some home-grown encryption or hashing, which is often a mistake. Look at mcrypt and hash instead.

EDIT: My initial answer was wrong about the cause of the infinite loop.


Check this out it will surely work


<?php
$key = 129;

$email = $_REQUEST["payer_email"];
$first = $_REQUEST["first_name"];
$last = $_REQUEST["last_name"];
$acode = $_REQUEST["hash"];

$txt = $email . "|" . $email . "|" . $first . "|" . $last . "|" . $acode;
$outtxt = '';

for($i=0;$i<strlen($txt);)
{
    for($j=0;$j<strlen($key);$j++,$i++)
    {
        $outtxt .=  ( $txt{ $i } ^ $key{$j} ) ;
    }
}

echo "thanks";
?>

Please see if this is the error fixed or comment me


There's not much to wonder about here. Your code is taking too long to run. You can increase the timeout limit in your PHP config files. I would however recommend that you use the command line PHP interpreter to see where your program is taking all these 30 seconds and then figure out how to optimise it.


Use set_time_limit(0) if you want to continue with your code which will ignore any timeout setting in php.ini.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号