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
    Jul 2002
    Location
    Florida, USA
    Posts
    96
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Magically adding slashes?

    Greetings, all.

    I have a series of pages on a site I maintain that are used to allow easy end-user updates. Recently I noticed they've developed a ton of extra slashes when the pages are updated, and for the life of me, I can't figure out where they're coming from.

    This is one block of links off of the admin page. The user selects a link to edit which calls edit.php to handle that link's content. Please overlook some of the bad CSS.
    PHP Code:
    Select a link to edit:
    <
    p align="left">

        <!-- 
    Informative stuff -->

        <
    table border="0" cellspacing="0" cellpadding="0" style="border-left:1px">
        <
    tr style="border-left:1px; border-color:#FFCCFF;">
        <
    td class="boxContents" style="border-left:1px">
            &
    nbsp;<strong><em>· </em></strong>
                <
    font class="menuText">
                    &
    nbsp;<a href="edit.php?page=text/index.txt">Affiliate Home</a>
                </
    font><br>
            &
    nbsp;<strong><em>· </em></strong>
                <
    font class="menuText">
                    &
    nbsp;<a href="edit.php?page=text/komenfacts.txt">Komen Facts</a>
                </
    font><br>
            &
    nbsp;<strong><em>· </em></strong>
                <
    font class="menuText">
                    &
    nbsp;<a href="edit.php?page=text/bcfacts.txt">Breast Cancer Facts</a>
                </
    font><br>
            &
    nbsp;<strong><em>· </em></strong>
                <
    font class="menuText">
                    &
    nbsp;<a href="edit.php?page=text/selfexam.txt">Breast Self-Exam</a>
                </
    font><br><br>
        </
    td>
        </
    tr>
        </
    table
    Edit.php then looks like this.. Simple page.

    PHP Code:
    <body bgcolor="#FFFFFF">

    <?php
    error_reporting
    (E_ALL);
    $filename $page;
    $handle fopen($filename"r");
    $contents fread($handlefilesize ($filename));
    fclose($handle);
    ?>

    <FORM ACTION="update.php" METHOD=POST>

    <strong>
    <font size="+1">Editting: <?php echo $page?></font>
    </strong>
    <BR>
    <TEXTAREA COLS="79" ROWS="30" NAME="contents">

    <?php echo $contents?>

    </TEXTAREA>

    <input value="<?php echo $page?>" type=HIDDEN name="pagename">
    <P>
    <INPUT TYPE=SUBMIT VALUE="submit">
    </FORM>
    Once the user submits the changes, update.php is called.
    PHP Code:
    <?php
    error_reporting
    (E_ALL);

    $page $_POST['pagename'];
    $filename $page;

    if (
    is_writable($filename))
    {

        if (!
    $handle fopen($filename'w'))
        {
             exit;
        }

        if (!
    fwrite($handle$_POST['contents']))
        {
            exit;
        }

        
    fclose($handle);
        echo 
    "Process completed... Finished writing " $filename "<br><br>";
        echo 
    "<a href=http://www.upstateraceforthecure.org/inc/admin.php>Admin</a> | ";
        echo 
    "<a href=http://www.upstateraceforthecure.org>Home</a>";

    }
    else
    {
        echo 
    "Cannot open file " .$filename " for writing. Check permissions.";
        echo 
    "<a href=http://www.upstateraceforthecure.org/inc/admin.php>Admin</a> | ";
        echo 
    "<a href=http://www.upstateraceforthecure.org>Home</a>";
    }
    ?>
    I can't see where these slashes are coming from, but when the pages are updated, anything with a " gets a \" and after several updates, end up looking like:

    The leading slashes are being stripped by the board, but there are also slashes before the first "justify in this example.
    PHP Code:
    <class="justify\\\\\\\\\\\\\\\"> 
    Thanks for any advice!

    Eric
    if ( bad && possible ) happen();
    Sig re-written for faster processing...

  • #2
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,280
    Thanks
    4
    Thanked 83 Times in 82 Posts
    Ironically enought it is magic.....well magic_quotes anyways. See previous thread on this

    http://www.codingforums.com/showthre...threadid=25516
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #3
    New Coder
    Join Date
    Jul 2002
    Location
    Florida, USA
    Posts
    96
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ahhh foot! Thanks Spookster!

    That did the trick.
    if ( bad && possible ) happen();
    Sig re-written for faster processing...


  •  

    Posting Permissions

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