Probleme php html with quote "
am 02.04.2008 12:54:46 von ClaudeHi
I try to read a variable $TITLE in e input firl type texte.
size='60'
maxlength='60'
value='$TITRE'>
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
Re: Probleme php html with quote "
am 02.04.2008 13:05:38 von GuillaumeClaude a écrit :
> Hi
> I try to read a variable $TITLE in e input firl type texte.
>
>
> size='60'
> maxlength='60'
> value='$TITRE'>
>
> 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
You should use double quote for every attribute in HTML.
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
Re: Probleme php html with quote "
am 02.04.2008 13:17:19 von colin.mckinnonOn 2 Apr, 13:08, Jerry Stuckle Jerry solution works well but I will try guillaume one to Claude schreef: Guillaume wrote: Erwin Moller a écrit : Jerry Stuckle a écrit : ..oO(Guillaume) ..oO(Jerry Stuckle) Guillaume wrote: To finish No I won't use both but only the one Jerry told us which works
> Guillaume wrote:
> > Claude a =E9crit :
> >> Hi
> >> I try to read a variable $TITLE in e input firl type texte.
> >> Name:
> >>
> >> name=3D'titre'
> >> size=3D'60'
> >> maxlength=3D'60'
> >> value=3D'$TITRE'>
> >> ";
> >> 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
>
> > You should use double quote for every attribute in HTML.
> >
=3D"
> > 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()).
>
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.
Re: Probleme php html with quote "
am 02.04.2008 13:32:01 von Claude
thank very much
claude
"Jerry Stuckle"
sNadnTUPIJqs9G7anZ2dnUVZ_sHinZ2d@comcast.com...
> Guillaume wrote:
>> Claude a écrit :
>>> Hi
>>> I try to read a variable $TITLE in e input firl type texte.
>>> Name:
>>>
>>> name='titre'
>>> size='60'
>>> maxlength='60'
>>> value='$TITRE'>
>>> ";
>>> 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
>>
>> You should use double quote for every attribute in HTML.
>>
>>
>> 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
> ==================
>
Re: Probleme php html with quote "
am 02.04.2008 14:01:11 von Erwin Moller
> 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"
> sNadnTUPIJqs9G7anZ2dnUVZ_sHinZ2d@comcast.com...
>> Guillaume wrote:
>>> Claude a écrit :
>>>> Hi
>>>> I try to read a variable $TITLE in e input firl type texte.
>>>> Name:
>>>>
>>>> name='titre'
>>>> size='60'
>>>> maxlength='60'
>>>> value='$TITRE'>
>>>> ";
>>>> 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
>>> You should use double quote for every attribute in HTML.
>>>
>>>
>>> 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
>> ==================
>>
>
>
Re: Probleme php html with quote "
am 02.04.2008 14:08:23 von Jerry Stuckle
> Claude a écrit :
>> Hi
>> I try to read a variable $TITLE in e input firl type texte.
>> Name:
>>
>> name='titre'
>> size='60'
>> maxlength='60'
>> value='$TITRE'>
>> ";
>> 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
>
> You should use double quote for every attribute in HTML.
>
>
> 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
==================
Re: Probleme php html with quote "
am 02.04.2008 14:14:42 von Guillaume
> Claude 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.
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,
--
GuillaumeRe: Probleme php html with quote "
am 02.04.2008 16:50:45 von Guillaume
> For newline characters there is nl2br().
Yep, but you might want something else (or nothing) than a "
" ^^
Regards,
--
GuillaumeRe: Probleme php html with quote "
am 02.04.2008 17:22:14 von Michael Fesser
>Claude a écrit :
>> Hi
>> I try to read a variable $TITLE in e input firl type texte.
>> Name:
>>
>> name='titre'
>> size='60'
>> maxlength='60'
>> value='$TITRE'>
>> ";
>> 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
>
>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
Re: Probleme php html with quote "
am 02.04.2008 17:22:15 von Michael Fesser
>For newline characters there is nl2br().
Only if you want XHTML, it's not suitable for HTML.
MichaRe: Probleme php html with quote "
am 02.04.2008 17:42:57 von Jerry Stuckle
> Erwin Moller a écrit :
>> Claude 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.
>
> 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
==================Re: Probleme php html with quote "
am 03.04.2008 19:05:22 von aorangi
fine
Regards
claude
"Michael Fesser"
iu87v35d1vrniabvjadvkfk98lo343m64m@4ax.com...
> .oO(Guillaume)
>
>>Claude a écrit :
>>> Hi
>>> I try to read a variable $TITLE in e input firl type texte.
>>> Name:
>>>
>>> name='titre'
>>> size='60'
>>> maxlength='60'
>>> value='$TITRE'>
>>> ";
>>> 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
>>
>>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