Base64_encode and Internal Server Error

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
toasty2
Forum Contributor
Posts: 361
Joined: Wed Aug 03, 2005 10:28 am
Location: Arkansas, USA

Base64_encode and Internal Server Error

Post 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.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

It's probably running out of memory or something. Can't really say without seeing code.
toasty2
Forum Contributor
Posts: 361
Joined: Wed Aug 03, 2005 10:28 am
Location: Arkansas, USA

Post 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.
toasty2
Forum Contributor
Posts: 361
Joined: Wed Aug 03, 2005 10:28 am
Location: Arkansas, USA

Post 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.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post 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);
}
?>
toasty2
Forum Contributor
Posts: 361
Joined: Wed Aug 03, 2005 10:28 am
Location: Arkansas, USA

Post by toasty2 »

Thank you so much :D
I haven't learned how to use loops yet :P :cry:
Post Reply