You are here: Re: preg_replace help? « PHP Programming Language « IT news, forums, messages
Re: preg_replace help?

Posted by Trammel on 07/28/07 02:35

> "Rik" <luiheidsgoeroe@hotmail.com> wrote in message
> news:op.tv5klmtiqnv3q9@metallium...
> On Sat, 28 Jul 2007 04:11:02 +0200, Trammel <Me@Server.com> wrote:
>
>> Im accepting user input from a text-box on a webpage.
>> I am then wanting to echo that back into the same box when the page is
>> submitted.
>>
>> The problem I have is that the input COULD contain multiple quotes and
>> double-quotes.
>> AddSlashes doesnt seem to work properly, as it turns ' into \'
>> ...and " just into \ (removing everything after)
>
> It doesn't, but you haven't shown your code and exact output, so I cannot
> tell you what the error there is.
>
>> I thought of using single-quotes for the Value='' and then use
>> preg_replace
>> to replace all occurances of ' with \' ...but I cant figure-out how to
>> do
>> it.
>>
>> Anyone got any idea?
>>
>> For example the user might have entered: ''''"""'"'"''"' (A collection
>> of
>> quotes & double-quotes)
>> The input is stored in $myVar... and needs to be put BACK inside Value=''
>
> If it's just HTML, use htmlspecialchars($myVar,ENT_QUOTES); On a submit of
> the form it will be the normal string again, so no worries there either.

htmlspecialchars($myVar) worked great, thanks :-)

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация