Escaping

Escaping

am 10.04.2008 21:44:33 von ahmad

Hello,

I am trying to output HTML and JavaScript using PHP as the following:


', '');" />


The $categoryName variable can contain single and double quotes, so
how can I escape them?

Thanks.

Re: Escaping

am 10.04.2008 22:14:06 von colin.mckinnon

On 10 Apr, 20:44, Ahmad wrote:
> Hello,
>
> I am trying to output HTML and JavaScript using PHP as the following:
>
>
> ', '');" />
>

>
> The $categoryName variable can contain single and double quotes, so
> how can I escape them?
>

Also losing the syntactic overkill:



C.

Re: Escaping

am 10.04.2008 22:48:34 von ahmad

On Apr 10, 11:14 pm, "C. (http://symcbean.blogspot.com/)"
wrote:
> On 10 Apr, 20:44, Ahmad wrote:
>
> > Hello,
>
> > I am trying to output HTML and JavaScript using PHP as the following:
>
> >
> > ', '');" />
> >

>
> > The $categoryName variable can contain single and double quotes, so
> > how can I escape them?
>
> Also losing the syntactic overkill:
>
>
>
> C.

That is right but I don't want to convert all HTML special characters
and how to convert the variables back on the javascript function?

Re: Escaping

am 11.04.2008 09:29:42 von alvaroNOSPAMTHANKS

Ahmad escribió:
>
> ', '');" />
>

>
> The $categoryName variable can contain single and double quotes, so
> how can I escape them?

With htmlspecialchars().

BTW, do you actually know what "{$categoryId}" does? You provide an
array and tell PHP to parse it to find variables and replace them with
their values. That could make sense with stuff like "Hello, $name\n" but
not with an array that just contains a variable.



--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://bits.demogracia.com
-- Mi web de humor al baño María: http://www.demogracia.com
--