Code Comments
Programming Forum and web based access to our favorite programming groups.Hi I try to read a variable $TITLE in e input firl type texte. <TR><TD WIDTH='100'> Name:</TD> <TD><input type='text' name='titre' size='60' maxlength='60' value='$TITRE'> </TD><TR>"; The probleme is when I have a quote in the title like mister O'Neil the field give only mister O. The quote has probleme with the html quote. how can I go around this problem regards claude
Post Follow-up to this messageClaude a écrit :
> Hi
> I try to read a variable $TITLE in e input firl type texte.
> <TR><TD WIDTH='100'> Name:</TD>
> <TD><input type='text'
> name='titre'
> size='60'
> maxlength='60'
> value='$TITRE'>
> </TD><TR>";
> The probleme is when I have a quote in the title like
> mister O'Neil the field give only mister O. The quote has probleme with th
e
> html quote.
> how can I go around this problem
> regards
> claude
You should use double quote for every attribute in HTML.
<input type="text" name="titre" size="60" maxlength="60" value="<?php
echo $TITRE; ?>" />
regarding special chars, an option is to use addslashes function. Or
just a str_replace('"', '\"', $TITRE) to handle the double quotes, same
could go for newlines, etc.
Regards,
--
Guillaume
Post Follow-up to this messageGuillaume wrote:
> Claude a écrit :
>
> You should use double quote for every attribute in HTML.
> <input type="text" name="titre" size="60" maxlength="60" value="<?php
> echo $TITRE; ?>" />
>
> regarding special chars, an option is to use addslashes function. Or
> just a str_replace('"', '\"', $TITRE) to handle the double quotes, same
> could go for newlines, etc.
>
> Regards,
The correct function to use here would be htmlspecialchars() (or
htmlentities()).
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Post Follow-up to this messageOn 2 Apr, 13:08, Jerry Stuckle <jstuck...@attglobal.net> wrote: > Guillaume wrote: > =3D"<?php > > > > The correct function to use here would be htmlspecialchars() (or > htmlentities()). > Jerry is right: html allows single quotes to be embedded within double quotes and viceversa - but obviously this does not account for every scenario. Watch out for what you get back - there are various irreversible versions of the magic quotes option. Going forward they are all deperecated. C.
Post Follow-up to this messageJerry solution works well but I will try guillaume one to thank very much claude "Jerry Stuckle" <jstucklex@attglobal.net> a écrit dans le message de news: sNadnTUPIJqs9G7anZ2dnUVZ_sHinZ2d@comcast .com... > Guillaume wrote: > > The correct function to use here would be htmlspecialchars() (or > htmlentities()). > > -- > ================== > Remove the "x" from my email address > Jerry Stuckle > JDS Computer Training Corp. > jstucklex@attglobal.net > ================== >
Post Follow-up to this messageClaude schreef: > Jerry solution works well but I will try guillaume one to > > thank very much > claude Hi Claude, Are you going to use them both? How? Just use htmlspecialchars(), it is designed for excactly your problem. Erwin Moller > "Jerry Stuckle" <jstucklex@attglobal.net> a écrit dans le message de news: > sNadnTUPIJqs9G7anZ2dnUVZ_sHinZ2d@comcast .com... > >
Post Follow-up to this messageErwin Moller a écrit : > Claude schreef: > > Hi Claude, > > Are you going to use them both? > How? > > Just use htmlspecialchars(), it is designed for excactly your problem. Well mine was lazy, since my main point actually was to use double quote on HTML attributes. Still using str_replace *can* be added in case the input might have newlines, which htmlspecialchars won't replace. But that is only for very special cases, it should usually not be useful in any way. Still, Jerry had the good point :p Regards, -- Guillaume
Post Follow-up to this messageGuillaume wrote: > Erwin Moller a écrit : > > Well mine was lazy, since my main point actually was to use double quote > on HTML attributes. > Still using str_replace *can* be added in case the input might have > newlines, which htmlspecialchars won't replace. But that is only for > very special cases, it should usually not be useful in any way. > > Still, Jerry had the good point :p > > Regards, For newline characters there is nl2br(). -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ==================
Post Follow-up to this messageJerry Stuckle a écrit : > For newline characters there is nl2br(). Yep, but you might want something else (or nothing) than a "<br />" ^^ Regards, -- Guillaume
Post Follow-up to this message..oO(Guillaume) >Claude a écrit : > >You should use double quote for every attribute in HTML. Single quotes are perfectly fine. And even with double quotes you have to escape some characters or you will have the same problem again. Micha
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.