Jump to content

Output issues


jcruz

Recommended Posts

Hello, everyone. I'm quite new to PHP; I'm mostly acquainted with Java.

I wrote an application in Java that could change the base the characters in a string to bases 2-104 and that would output the string. After many, many headaches, I ported some of it to PHP. However, this code segment is not working for some odd reason. I have error reporting enabled in both PHP and Apache, yet I get no errors.

Any help would be greatly appreciated!

This is the code segment that is giving me trouble:

[code]elseif ($_POST['Encode'])
{

$input = $_POST['dectxt'];
$output = "";
for($counter = 0;$counter < (strlen($input));$counter++)
{
  $temp = ord(substr($input,$counter,1));
  if($temp > 255)
  {
  $output = "Invalid character detected.";
  break;
  }
  $temp2 = $marray[($POST_['base'])-2][temp];
  $output = $output.$temp2;
}

echo "<form action='index.php' method='POST'>
Text:<br><textarea cols='40' rows='10' wrap='virtual' name='dectxt'>" . $input . "</textarea><br>
Base:<br><input type='text' size='3' value='" . $_POST['base'] . "' name='base'><br>
<input type='submit' value='Encode' name='Encode'><br>
Text:<br><textarea cols='40' rows='10' wrap='virtual' name='enctxt'>" . $output . "</textarea><br>
<input type='submit' value='Decode' name='Decode'>";
}[/code]
Link to comment
https://forums.phpfreaks.com/topic/33686-output-issues/
Share on other sites

[quote author=jesirose link=topic=121877.msg501904#msg501904 date=1168483537]
you can always type php.net/(function) to get info on a function you don't know about :)
[/quote]

Oh? Hmm, thanks for the advice! :)

I tried print_r, and all the variables were correctly displayed. =/

[code]Array ( [dectxt] => H [base] => 2 [Encode] => Encode [enctxt] => D )[/code]

Also, I noticed that in the $marray[][temp], a $ was missing. I added it, but still no dice.
Link to comment
https://forums.phpfreaks.com/topic/33686-output-issues/#findComment-157916
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.