Page 1 of 1

i have a problem with javascript into php (simple problem)

Posted: Mon Jun 25, 2012 11:59 am
by mekha
i have a problem with javascript into php (simple problem)
--------
when i edit the database manualy... my code is:

Code: Select all


<script type="text/javascript">google_ad_client = "zzzz";

google_ad_slot = "zzzz";
google_ad_width = 160;
google_ad_height = 600;

</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>

but with a control panel ($_POST)....my code changes to:

Code: Select all


<script type=\"text/javascript\">google_ad_client =\ "zzzz\";

google_ad_slot =\ "zzzz\";
google_ad_width = 160;
google_ad_height = 600;

</script>
<script type=\"text/javascript\"
src=\"http://pagead2.googlesyndication.com/pagead/show_ads.js\">
</script>

i mean:
with control panel $_POST: before the ' " ' i have /...like this: ' \" '
database manualy: with no problem...without \...
any solutions :S ?

Re: i have a problem with javascript into php (simple proble

Posted: Mon Jun 25, 2012 9:57 pm
by requinix
Turn off the magic_quotes setting in your php.ini.

Re: i have a problem with javascript into php (simple proble

Posted: Tue Jun 26, 2012 2:48 am
by mekha
if i turn it off...its have only effects on the database? or in all php codes ?
because i am using a \' with javascript a php code (into echo) i mean...i have some php codes that include javascript...and i used the \ before the '....if i turn it off..is it affect on the php code ?

Re: i have a problem with javascript into php (simple proble

Posted: Tue Jun 26, 2012 3:06 am
by requinix
magic_quotes will effectively addslashes() all user input. Not output.

And if you're echoing stuff into JavaScript then don't try to escape it yourself and use json_encode instead.