Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Feb 2003
    Location
    New York, USA
    Posts
    28
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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

  • #2
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,266
    Thanks
    6
    Thanked 48 Times in 48 Posts
    You'll need stripslashes()

  • #3
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •