Textarea handling in php ? | | |
I'm learning a little about using forms in php to enter data, and have a
couple of questions re textarea.
At the moment I just use "addslashes() to process the value from textarea so
that punctuation is escaped, and write this into a table.
When the text wraps in the text box I get a new line in the value returned,
as well as new lines that I enter manually.
Is it possible to remove the wrap new line but keep the user entered new
line ? | | | | re: Textarea handling in php ?
Tony B wrote: Quote:
I'm learning a little about using forms in php to enter data, and have a
couple of questions re textarea.
At the moment I just use "addslashes() to process the value from textarea so
that punctuation is escaped, and write this into a table.
When the text wraps in the text box I get a new line in the value returned,
as well as new lines that I enter manually.
Is it possible to remove the wrap new line but keep the user entered new
line ?
>
>
>
>
First of all, you shouldn't be using addslashes(). If you're writing to
a MySQL database, you should be using mysql_real_escape_string() instead.
As for the new lines - how is your code to know which are inserted by
the textarea and which are inserted by the user? Better to use send the
data correctly in the first place. See the WRAP attribute of a textarea .
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp. jstucklex@attglobal.net
================== | | | | re: Textarea handling in php ?
On 18 Mar, 12:18, Jerry Stuckle <jstuck...@attglobal.netwrote: Quote:
Tony B wrote: Quote:
I'm learning a little about using forms in php to enter data, and have a
As for the new lines - how is your code to know which are inserted by
the textarea and which are inserted by the user? Better to use send the
data correctly in the first place. See the WRAP attribute of a textarea .
>
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================
Surely that should have been: "Better to use send the data correctly
in the first place. See the WRAP attribute of a textarea. But this
has nothing to do with php.
;-) | | | | re: Textarea handling in php ?
Captain Paralytic wrote: Quote:
On 18 Mar, 12:18, Jerry Stuckle <jstuck...@attglobal.netwrote: Quote:
>Tony B wrote: Quote:
>>I'm learning a little about using forms in php to enter data, and have a
>As for the new lines - how is your code to know which are inserted by
>the textarea and which are inserted by the user? Better to use send the
>data correctly in the first place. See the WRAP attribute of a textarea .
>>
>--
>==================
>Remove the "x" from my email address
>Jerry Stuckle
>JDS Computer Training Corp.
>jstuck...@attglobal.net
>==================
>
Surely that should have been: "Better to use send the data correctly
in the first place. See the WRAP attribute of a textarea. But this
has nothing to do with php.
>
;-)
>
True. :-)
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp. jstucklex@attglobal.net
================== | | | | re: Textarea handling in php ?
"Tony B" <tagb61@yahoo.co.ukwrote in message
news:aeNDj.98509$FE.91698@fe05.news.easynews.com.. . Quote:
I'm learning a little about using forms in php to enter data, and have a
couple of questions re textarea.
At the moment I just use "addslashes() to process the value from textarea
so that punctuation is escaped, and write this into a table.
When the text wraps in the text box I get a new line in the value
returned, as well as new lines that I enter manually.
Is it possible to remove the wrap new line but keep the user entered new
line ?
>
>
IIRD, "wrap" is not an attribute of textarea in any version of html or xhtml
I've used - it's a proprietary attribute of Netscape/IE. You're just asking
for cross-browser trouble if you use it. Check out the white-space attribute
of CSS.
If this is for web display and you need to generate a hard new line in html,
use <br />. | | | | re: Textarea handling in php ?
First of all, you shouldn't be using addslashes(). If you're writing to a Quote:
MySQL database, you should be using mysql_real_escape_string() instead.
>
As for the new lines - how is your code to know which are inserted by the
textarea and which are inserted by the user? Better to use send the data
correctly in the first place. See the WRAP attribute of a textarea .
>
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp. jstucklex@attglobal.net
==================
Thanks for the pointer. I wasn't worried about sql injection as these are
not on public pages, but worth knowing for the future.
The wrap attribute does what I need.
Thanks
Tony | | | | re: Textarea handling in php ?
Tony B wrote: Quote: Quote:
>First of all, you shouldn't be using addslashes(). If you're writing to a
>MySQL database, you should be using mysql_real_escape_string() instead.
>>
>As for the new lines - how is your code to know which are inserted by the
>textarea and which are inserted by the user? Better to use send the data
>correctly in the first place. See the WRAP attribute of a textarea .
>>
>--
>==================
>Remove the "x" from my email address
>Jerry Stuckle
>JDS Computer Training Corp.
> jstucklex@attglobal.net
>==================
Thanks for the pointer. I wasn't worried about sql injection as these are
not on public pages, but worth knowing for the future.
The wrap attribute does what I need.
Thanks
Tony
>
>
>
You need to be worried about SQL injection, especially on internal
sites. More damage can be done by disgruntled employees than hackers.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp. jstucklex@attglobal.net
================== | | | | re: Textarea handling in php ?
"Mason Barge" <masonbarge@comcast.netwrote in message
news:V6ednVp9S-mLKULanZ2dnUVZ_qCunZ2d@comcast.com... Quote:
>
"Tony B" <tagb61@yahoo.co.ukwrote in message
news:aeNDj.98509$FE.91698@fe05.news.easynews.com.. . Quote:
>I'm learning a little about using forms in php to enter data, and have a
>couple of questions re textarea.
>At the moment I just use "addslashes() to process the value from textarea
>so that punctuation is escaped, and write this into a table.
>When the text wraps in the text box I get a new line in the value
>returned, as well as new lines that I enter manually.
>Is it possible to remove the wrap new line but keep the user entered new
>line ?
>>
>>
>
IIRD, "wrap" is not an attribute of textarea in any version of html or
xhtml I've used - it's a proprietary attribute of Netscape/IE. You're
just asking for cross-browser trouble if you use it. Check out the
white-space attribute of CSS.
>
If this is for web display and you need to generate a hard new line in
html, use <br />.
What I want is textarea not to insert line breaks just because the user
enters a line that is longer than the number of columns. Wrap can do this in
IE/FF/Opera etc.
I cannot see how css can alter the behaviour of textarea as to whether it
inserts hard line breaks when a line wraps in the textarea box ? | | | | re: Textarea handling in php ?
On 19 Mar, 09:31, "Tony B" <to...@imageproc.comwrote: Quote:
I cannot see how css can alter the behaviour of textarea as to whether it
inserts hard line breaks when a line wraps in the textarea box ?
Cannot see or haven't tried to?
I put
css white-space
into Gogle and pressed "I'm Feeling Lucky" and got a pretty good
explanation. | | | | re: Textarea handling in php ?
On 19 Mar, 09:57, Captain Paralytic <paul_laut...@yahoo.comwrote: Quote:
On 19 Mar, 09:31, "Tony B" <to...@imageproc.comwrote:I cannot see how css can alter the behaviour of textarea as to whether it Quote:
inserts hard line breaks when a line wraps in the textarea box ?
>
Cannot see or haven't tried to?
I put
css white-space
into Gogle and pressed "I'm Feeling Lucky" and got a pretty good
explanation.
And this explains even better: http://www.w3.org/TR/CSS21/text.html#white-space-prop | | | | re: Textarea handling in php ?
Captain Paralytic wrote: Quote:
On 19 Mar, 09:31, "Tony B" <to...@imageproc.comwrote: Quote:
>I cannot see how css can alter the behaviour of textarea as to whether it
>inserts hard line breaks when a line wraps in the textarea box ?
Cannot see or haven't tried to?
I put
css white-space
into Gogle and pressed "I'm Feeling Lucky" and got a pretty good
explanation.
>
That doesn't stop the insertion of a line break when the text wraps. It
just controls whether the line wraps or not.
No, "wrap" is not an HTML attribute, but it is supported every recent
browser I've tried.
And for Tony, <br /is not a valid html break.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp. jstucklex@attglobal.net
================== | | | | re: Textarea handling in php ?
Captain Paralytic wrote: Quote:
On 19 Mar, 09:57, Captain Paralytic <paul_laut...@yahoo.comwrote: Quote:
>On 19 Mar, 09:31, "Tony B" <to...@imageproc.comwrote:I cannot see how css can alter the behaviour of textarea as to whether it Quote:
>>inserts hard line breaks when a line wraps in the textarea box ?
>Cannot see or haven't tried to?
>I put
>css white-space
>into Gogle and pressed "I'm Feeling Lucky" and got a pretty good
>explanation.
>
And this explains even better: http://www.w3.org/TR/CSS21/text.html#white-space-prop
>
Ah, yes - now I see...
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp. jstucklex@attglobal.net
================== | | | | re: Textarea handling in php ?
On 19 Mar, 12:01, Jerry Stuckle <jstuck...@attglobal.netwrote: Quote:
Captain Paralytic wrote: Quote:
On 19 Mar, 09:57, Captain Paralytic <paul_laut...@yahoo.comwrote: Quote:
On 19 Mar, 09:31, "Tony B" <to...@imageproc.comwrote:I cannot see how css can alter the behaviour of textarea as to whether it
>inserts hard line breaks when a line wraps in the textarea box ?
Cannot see or haven't tried to?
I put
css white-space
into Gogle and pressed "I'm Feeling Lucky" and got a pretty good
explanation.
> >
Ah, yes - now I see...
Yes, as has been metioned in recent threads, w3schools is good for an
introduction, but it doesn't always tell one the whole truth.
I do think that this particular w3.org section is one of their clearer
ones. | | | | re: Textarea handling in php ?
Jerry Stuckle wrote: Quote:
And for Tony, <br /is not a valid html break.
"<br/>" is valid in HTML. It just doesn't mean what people think it means.
It is equivalent to "<br>>" because of SGML shorttag rules.
--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 1 day, 13:37.]
The Semantic Web http://tobyinkster.co.uk/blog/2008/03/09/sw/ | | | | re: Textarea handling in php ?
Captain Paralytic wrote: Quote:
Yes, as has been metioned in recent threads, w3schools is good for an
introduction, but it doesn't always tell one the whole truth. I do think
that this particular w3.org section is one of their clearer ones.
w3.org and w3schools.com are entirely different websites. Do not get them
mixed up.
w3.org is the World Wide Web Consortium (W3C), an organisation set up by
Sir Tim Berners-Lee to steer the development of the web, supported by many
academic organisations, browser makers and content producers. They have
been responsible for all HTML specifications since version 3.2, and for
CSS, the DOM, XML, SVG, RDF, SOAP and various other web-related
technologies. This responsibility for them has been informally delegated
to them by the IETF.
w3schools.com is a tutorial website owned by a small Norwegian company
called Refsnes Data. Although their tutorials are generally fairly good,
the company is in no way affiliated with the W3C, and their tutorials are
no more "official" than any turoial you or I could put together. Most of
their tutorials are aimed at helping your learn W3C standards, and other
web-related technologies.
--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 1 day, 13:56.]
The Semantic Web http://tobyinkster.co.uk/blog/2008/03/09/sw/ | | | | re: Textarea handling in php ?
On Wed, 19 Mar 2008 12:53:50 +0100, Toby A Inkster
<usenet200803@tobyinkster.co.ukwrote: Quote:
Jerry Stuckle wrote:
> Quote:
>And for Tony, <br /is not a valid html break.
>
"<br/>" is valid in HTML. It just doesn't mean what people think it
means.
It is equivalent to "<br>>" because of SGML shorttag rules.
..... extending up to the next /.
('<br/>I don't know / don't care' == '<br>>I don't know</brdon't care)
No mainstream UA interprets it like that to my knowledge, but mixing HTML
& XHTML is still a bad idea indeed.
--
Rik Wasmus | | | | re: Textarea handling in php ?
Toby A Inkster wrote: Quote:
Jerry Stuckle wrote:
> Quote:
>And for Tony, <br /is not a valid html break.
>
"<br/>" is valid in HTML. It just doesn't mean what people think it means.
It is equivalent to "<br>>" because of SGML shorttag rules.
>
Actually, it's not valid. It's only valid in XHTML. Most browsers
accept it, but that doesn't mean it's legal.
In HTML 4.01. the end tag is forbidden. See http://www.w3.org/TR/html401/struct/text.html#edef-BR
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp. jstucklex@attglobal.net
================== | | | | re: Textarea handling in php ?
Rik Wasmus wrote: Quote:
Toby A Inkster wrote: Quote:
>>
>"<br/>" is valid in HTML. It just doesn't mean what people think it
>means. It is equivalent to "<br>>" because of SGML shorttag rules.
>
.... extending up to the next /.
('<br/>I don't know / don't care' == '<br>>I don't know</brdon't
care)
In the case of something like <b/>.../ or <p/>.../ you would be right, but
the HTML DTD explicitly declares the <brelement to be empty, so no
second slash is required to close the element. Quote:
No mainstream UA interprets it like that to my knowledge
Nope. And a good thing too -- otherwise the backwards compatibility of
XHTML wouldn't "work".
--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 1 day, 19:28.]
The Semantic Web http://tobyinkster.co.uk/blog/2008/03/09/sw/ | | | | re: Textarea handling in php ?
Jerry Stuckle wrote: Quote:
Toby A Inkster wrote:
> Quote:
>"<br/>" is valid in HTML. It just doesn't mean what people think it
>means. It is equivalent to "<br>>" because of SGML shorttag rules.
>
Actually, it's not valid.
Actually it is: http://examples.tobyinkster.co.uk/br/br
--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 1 day, 19:28.]
The Semantic Web http://tobyinkster.co.uk/blog/2008/03/09/sw/ | | | | re: Textarea handling in php ?
Toby A Inkster wrote: Quote:
Jerry Stuckle wrote: Quote:
>Toby A Inkster wrote:
>> Quote:
>>"<br/>" is valid in HTML. It just doesn't mean what people think it
>>means. It is equivalent to "<br>>" because of SGML shorttag rules.
>Actually, it's not valid.
>
Actually it is: http://examples.tobyinkster.co.uk/br/br
>
See the rest of my message - and the link to the W3C spec which shows it
is NOT valid.
Just because the validator doesn't catch the error does not mean it's valid.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp. jstucklex@attglobal.net
================== | | | | re: Textarea handling in php ?
..oO(Jerry Stuckle) Quote:
>Toby A Inkster wrote: Quote:
>Jerry Stuckle wrote: Quote:
>>Toby A Inkster wrote:
>>>
>>>"<br/>" is valid in HTML. It just doesn't mean what people think it
>>>means. It is equivalent to "<br>>" because of SGML shorttag rules.
>>Actually, it's not valid.
>>
>Actually it is:
> http://examples.tobyinkster.co.uk/br/br
>>
>
>See the rest of my message - and the link to the W3C spec which shows it
>is NOT valid.
<br/means completely different things in HTML and XHTML. Following
SGML minimization rules the slash implicitly closes the start tag and
there's no end tag. The following is just character data. http://www.cs.tut.fi/~jkorpela/html/empty.html#why
You could replace the with whatever you like: x<br/y is perfectly
valid HTML and should render as
x
y
but of course it won't in most browsers. Quote:
>Just because the validator doesn't catch the error does not mean it's valid.
The validator doesn't catch it because in this case it is not an error.
Micha |  | | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,295 network members.
|