Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rating: Thread Rating: 6 votes, 2.33 average.
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-31-2003, 06:11 PM   PM User | #1
NYColt
New Coder

 
Join Date: Feb 2003
Location: New York, USA
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
NYColt is an unknown quantity at this point
Question PHP adds \\\ to a script

Hello again everyone.

I am sending this script to a page:

<!-- ADDFREESTATS.COM CODE V2 (Normal Page) -->
<!-- CODE FOR YOUR PAGE: Houston -->
<!-- URL : http://mysitename.com/ -->
<!-- PAGE NUMBER :12 -->
<center>
<SCRIPT language="javascript"><!--
document.write("<a href=\"http://top.addfreestats.com/cgi-bin/main.cgi?usr=00234154P012\" target=\"_blank\">");
document.write("<img src=\"http://www2.addfreestats.com");
document.write("/cgi-bin/connect.cgi?");
document.write("usr=00234154P012");
document.write("&refer="+escape(document.referrer)+"");
document.write("&tips="+Math.random()+"");
document.write("\" alt=\"AddFreeStats\" border=0></A>");
//--></SCRIPT>
<noscript>
<a href="http://top.addfreestats.com/cgi-bin/main.cgi?usr=00234154P012" target="_blank">
<img src="http://www2.addfreestats.com/cgi-bin/connect.cgi?usr=00234154P012" border=0 alt="AddFreeStats.com Free Web Stats in real-time !"></A>
</noscript>
</center>
<!-- http://www.addfreestats.com -->

<!-- END ADDFREESTATS.COM NORMAL CODE V2 - Free Web Stats -->

And the souce code result on the PHP page I send it to is this:

<!-- ADDFREESTATS.COM CODE V2 (Normal Page) -->
<!-- CODE FOR YOUR PAGE: Houston -->
<!-- URL : http://mywebsitename.com/ -->
<!-- PAGE NUMBER :12 -->
<center>
<SCRIPT language=\"javascript\"><!--
document.write(\"<a href=\\\"http://top.addfreestats.com/cgi-bin/main.cgi?usr=00234154P012\\\" target=\\\"_blank\\\">\");
document.write(\"<img src=\\\"http://www2.addfreestats.com\");
document.write(\"/cgi-bin/connect.cgi?\");
document.write(\"usr=00234154P012\");
document.write(\"&refer=\"+escape(document.referrer)+\"\");
document.write(\"&tips=\"+Math.random()+\"\");
document.write(\"\\\" alt=\\\"AddFreeStats\\\" border=0></A>\");
//--></SCRIPT>
<noscript>
<a href=\"http://top.addfreestats.com/cgi-bin/main.cgi?usr=00234154P012\" target=\"_blank\">
<img src=\"http://www2.addfreestats.com/cgi-bin/connect.cgi?usr=00234154P012\" border=0 alt=\"AddFreeStats.com Free Web Stats in real-time !\"></A>
</noscript>
</center>
<!-- http://www.addfreestats.com -->

<!-- END ADDFREESTATS.COM NORMAL CODE V2 - Free Web Stats -->

As you can see php has added a bunch of backslashes to the code.

Does anyone have any idea hopw I can prevent this from happening?

Thanks
NYColt
NYColt is offline   Reply With Quote
Old 10-31-2003, 06:49 PM   PM User | #2
Nightfire
Senior Coder

 
Nightfire's Avatar
 
Join Date: Jun 2002
Posts: 4,266
Thanks: 6
Thanked 48 Times in 48 Posts
Nightfire is on a distinguished road
You'll need stripslashes()
__________________
Blue Panda
Website Design | 1 Pound Ads | 'ow much? | Coding Geeks
Nightfire is offline   Reply With Quote
Old 10-31-2003, 09:54 PM   PM User | #3
missing-score
Senior Coder


 
missing-score's Avatar
 
Join Date: Jan 2003
Location: UK
Posts: 2,194
Thanks: 0
Thanked 0 Times in 0 Posts
missing-score is on a distinguished road
you may also want to look at http://www.php.net/set-magic-quotes-runtime

if you have "magic quotes" enabled, php will add slashes to your quotes. you could try:

set_magic_quotes_runtime(0);

at the top of your script
missing-score is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:08 PM.


Advertisement
Log in to turn off these ads.