Php html content variable into textbox/textarea?

SORRY PROBLEM SOLVED !!! the following code does work for displaying mulitiline code its just that some previous code had erased the contents of my verbatim.txt … sorry!

[B]
<?php $data = file_get_contents(“verbatim.txt”);?>

<textarea id=“text” name=“text” cols=“120” rows=“20” style=“width: 700px; height: 500px”>

<?php print_r ($data);?>

</textarea>[/B]

Sorry i’m tripping up all over the place at teh moment with this code!

First i turned apache off and forgot to restart it,
then i renamed the file and did lots of work on it and kept the original filename in my URL and wondered why it didnt change for half an hour, tapping furiously,

Then i interrupted a long variable chain and erased my text and nothing was coming up in the print anymore when it was just earlier, and i didnt understand…

Sorry!

total Noob!!!

Try converting all the special characters to entities so that you dont have problem with them.


<?php $data = file_get_contents("verbatim.txt");?>
<textarea id="text" name="text" cols="120" rows="20" style="width: 700px; height: 500px">
<?php echo htmlentities($data); ?> 
</textarea>

Suggestion:

<?php $data = file_get_contents("verbatim.txt");?>
<textarea id="text" name="text" cols="120" rows="20" style="width: 700px; height: 500px">
<?php echo htmlentities($data); ?>
</textarea>

Change this code to

<?php $data = file_get_contents("verbatim.txt");?>
<textarea id="text" name="text" cols="120" rows="20" style="width: 700px; height: 500px"><?php echo htmlentities($data); ?></textarea>

Did anyone noted the changes?

Yes I noted it. It should be in a single line so that it prevents from injecting extra lines before/after the actual value in textarea.

Am I right?

Yes exactly.
The condition become worse when you don’t filter the data $_POST[‘text’], the extra space gets accumulated in the DB.

I still have a problem.

echo $data;
prints:
msgstr “Úloha Expirace ve střednÃÂ* formát”

but
$handle = fopen(“xc2.txt”, “wb”);
fseek($handle, 0);
fwrite($handle, $data);
fclose($handle);

saves the fonts the right way:

msgstr “Úloha Expirace ve střední formát”

Ok i did this to fix it:

<meta http-equiv=“Content-Type” content=“text/html; charset=utf-8” />
at the top of the HTML.

now the textfield prints the good fonts, but if i echo the html characters it prints:

msgstr “�loha Expirace ve st?edn� form�t”

Oh… that is another problem. Anyway good to hear that you sorted it out.