Page 1 of 1

Base64_encode and Internal Server Error

Posted: Wed Aug 09, 2006 3:26 pm
by toasty2
I made a script that would do base64_encode to a string 3 times and it worked fine. Then, to raise the bar (a ton) I had it do it 64 times to the string. Now when I try to use it, I get "Internal Server Error", I use a webhost. What causes it? Is a certain restriction stopping it? I realize 64 times is a ton, but I wanted to try it.

Posted: Wed Aug 09, 2006 3:44 pm
by Chris Corbyn
It's probably running out of memory or something. Can't really say without seeing code.

Posted: Wed Aug 09, 2006 3:50 pm
by toasty2

Code: Select all

<?php
// Base64 experimentation
if ($q == null)
{die("No query specified");}
elseif ($q == "encode")
{
$txt = base64_encode($txt);
$txt = base64_encode($txt);
$txt = base64_encode($txt);
$txt = base64_encode($txt);
$txt = base64_encode($txt);
$txt = base64_encode($txt);
$txt = base64_encode($txt);
$txt = base64_encode($txt);
$txt = base64_encode($txt);
$txt = base64_encode($txt);
$txt = base64_encode($txt);
$txt = base64_encode($txt);
$txt = base64_encode($txt);
$txt = base64_encode($txt);
$txt = base64_encode($txt);
$txt = base64_encode($txt);
$txt = base64_encode($txt);
$txt = base64_encode($txt);
$txt = base64_encode($txt);
$txt = base64_encode($txt);
$txt = base64_encode($txt);
$txt = base64_encode($txt);
$txt = base64_encode($txt);
$txt = base64_encode($txt);
$txt = base64_encode($txt);
$txt = base64_encode($txt);
$txt = base64_encode($txt);
$txt = base64_encode($txt);
$txt = base64_encode($txt);
$txt = base64_encode($txt);
$txt = base64_encode($txt);
$txt = base64_encode($txt);
$txt = base64_encode($txt);
$txt = base64_encode($txt);
$txt = base64_encode($txt);
$txt = base64_encode($txt);
$txt = base64_encode($txt);
$txt = base64_encode($txt);
$txt = base64_encode($txt);
$txt = base64_encode($txt);
$txt = base64_encode($txt);
$txt = base64_encode($txt);
$txt = base64_encode($txt);
$txt = base64_encode($txt);
$txt = base64_encode($txt);
$txt = base64_encode($txt);
$txt = base64_encode($txt);
$txt = base64_encode($txt);
$txt = base64_encode($txt);
$txt = base64_encode($txt);
$txt = base64_encode($txt);
$txt = base64_encode($txt);
$txt = base64_encode($txt);
$txt = base64_encode($txt);
$txt = base64_encode($txt);
$txt = base64_encode($txt);
$txt = base64_encode($txt);
$txt = base64_encode($txt);
$txt = base64_encode($txt);
$txt = base64_encode($txt);
$txt = base64_encode($txt);
$txt = base64_encode($txt);
$txt = base64_encode($txt);
$txt = base64_encode($txt);
echo ($txt);
}
elseif ($q == "decode")
{
$txt = base64_decode($txt);
$txt = base64_decode($txt);
$txt = base64_decode($txt);
$txt = base64_decode($txt);
$txt = base64_decode($txt);
$txt = base64_decode($txt);
$txt = base64_decode($txt);
$txt = base64_decode($txt);
$txt = base64_decode($txt);
$txt = base64_decode($txt);
$txt = base64_decode($txt);
$txt = base64_decode($txt);
$txt = base64_decode($txt);
$txt = base64_decode($txt);
$txt = base64_decode($txt);
$txt = base64_decode($txt);
$txt = base64_decode($txt);
$txt = base64_decode($txt);
$txt = base64_decode($txt);
$txt = base64_decode($txt);
$txt = base64_decode($txt);
$txt = base64_decode($txt);
$txt = base64_decode($txt);
$txt = base64_decode($txt);
$txt = base64_decode($txt);
$txt = base64_decode($txt);
$txt = base64_decode($txt);
$txt = base64_decode($txt);
$txt = base64_decode($txt);
$txt = base64_decode($txt);
$txt = base64_decode($txt);
$txt = base64_decode($txt);
$txt = base64_decode($txt);
$txt = base64_decode($txt);
$txt = base64_decode($txt);
$txt = base64_decode($txt);
$txt = base64_decode($txt);
$txt = base64_decode($txt);
$txt = base64_decode($txt);
$txt = base64_decode($txt);
$txt = base64_decode($txt);
$txt = base64_decode($txt);
$txt = base64_decode($txt);
$txt = base64_decode($txt);
$txt = base64_decode($txt);
$txt = base64_decode($txt);
$txt = base64_decode($txt);
$txt = base64_decode($txt);
$txt = base64_decode($txt);
$txt = base64_decode($txt);
$txt = base64_decode($txt);
$txt = base64_decode($txt);
$txt = base64_decode($txt);
$txt = base64_decode($txt);
$txt = base64_decode($txt);
$txt = base64_decode($txt);
$txt = base64_decode($txt);
$txt = base64_decode($txt);
$txt = base64_decode($txt);
$txt = base64_decode($txt);
$txt = base64_decode($txt);
$txt = base64_decode($txt);
$txt = base64_decode($txt);
$txt = base64_decode($txt);
echo ($txt);
}
?>
Sorry it's so long :D
You have to goto the page and add "?q=encode&txt=<what_you_want_to_encode>" to use it.

Posted: Wed Aug 09, 2006 9:38 pm
by toasty2
It works plenty well (and is plenty long) when I only do it 20 times (link), but I think it would be awesome to do it 64 times.

Posted: Wed Aug 09, 2006 9:51 pm
by Weirdan
isn't that what loops are for?

Code: Select all

<?php
// Base64 experimentation
$i = 64;
if ($q == null){
  die("No query specified");
} elseif ($q == "encode") {
   while($i-->0) {
      $txt = base64_encode($txt);
   }
   echo ($txt);
} elseif ($q == "decode") {
   while($i-->0) {
      $txt = base64_decode($txt);
   }
   echo ($txt);
}
?>

Posted: Wed Aug 09, 2006 9:57 pm
by toasty2
Thank you so much :D
I haven't learned how to use loops yet :P :cry: