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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mekha
Forum Contributor
Posts: 112
Joined: Sat Mar 31, 2012 6:50 am

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

Post 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 ?
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

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

Post by requinix »

Turn off the magic_quotes setting in your php.ini.
mekha
Forum Contributor
Posts: 112
Joined: Sat Mar 31, 2012 6:50 am

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

Post 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 ?
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

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

Post 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.
Post Reply