...

View Full Version : PHP adds \\\ to a script



NYColt
10-31-2003, 07:11 PM
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

Nightfire
10-31-2003, 07:49 PM
You'll need stripslashes() (http://php.net/stripslashes)

missing-score
10-31-2003, 10:54 PM
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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum