View Full Version : Textarea Inside Textarea
ethernetcable
03-28-2004, 04:48 PM
Hello,
I have a problem with putting a textarea with html code inside. I am extracting the code from a database and where I have <textarea></teaxtarea> it closes both text areas. I was woundering if anybody could help me with this problem.
http://ethernetcable.net/?page=mod_custom
Thank You,
Ian
soccerdudez8
03-28-2004, 07:51 PM
Try the use of PHP's built in function, htmlentities() to replace < and > characters with < and >. It then displays as a html tag.
For example
<?php
$text = "Display this in a textarea
";
?>
<textarea><?php echo htmlentities($text);?></textarea>
See the PHP documentation (http://us4.php.net/manual/en/function.htmlentities.php) for more info on how to use this function.
ethernetcable
03-28-2004, 11:39 PM
Thank you for your help. I did that and all it says is "Resource id #4". I edited the page after you told me what to do and it overwrote what I had and now only says "Resource id #4". I have no idea where it gets that from. The url is http://ethernetcable.net/?page=customorder
and http://ethernetcable.net/?page=mod_custom.
I have the code for mod_custom.php attached. If you could tell me whats wrong I would greatly appreciate it.
Thanks,
Ian
soccerdudez8
03-29-2004, 07:30 PM
Is custom a constant?
(I am talking about the part on line 12 that says $row[custom].)
If custom isn't a constant, then you are attempting to access the array incorrectly. When you want to read data from an array, the key should be inside quotes. ($row["custom"]).
Another note: When PHP writes something like Resource id #4 that means that you are attempting to write a resource as a string. PHP does a wonderful job of converting variable types, and when a resource is to be printed, PHP makes it nice to read. $row[custom] is a resource, and not a string, as you expected. If PHP were to write a resource as a string without making it user-friendly to read, it would probably be a very long binary string.
Yet another note: Inside the htmlentities() function, you have $row inside double quotes so that PHP will parse the string and add the value of $row["custom"]. I have found that when you want PHP to parse in an array variable, you need to enclose the array variable in brackets. If you really wanted to do it this way, you could write htmlentities("{$row["custom"]}") There is no need for this. You could simply pass the variable to the array like this: htmlentities($row["custom"]). You should recieve the same output if you had used htmlentities("{$row["custom"]}") .
This may be mind boggling to you because I am not the best at explaining things, so in a nutshell, PHP is reading the value of $row and not $row["custom"].
vBulletin® v3.7.0, Copyright ©2000-2009, Jelsoft Enterprises Ltd.