Results 1 to 5 of 5

Thread: [RESOLVED] mysql_real_escape_string problem

  1. #1

    Thread Starter
    Addicted Member kzatu's Avatar
    Join Date
    Aug 2003
    Location
    Nevada
    Posts
    148

    Resolved [RESOLVED] mysql_real_escape_string problem

    I am having a problem when a user submits specific text to my database. If the user types a UNC path to a server and the server starts with an 'R' then the data is malformed as it gets entered into the mySQL database.

    For example, if the user types
    \\realtime\sharename
    I submit the data to the database using the mysql_real_escape_string. Which changes the data to now read
    \\\r\nealtime\\sharename
    This causes a problem when pulling the data out of the database and displaying it because of that \r\n. It does some tricky formatting and then the data printed in HTML looks like
    \ ealtime\sharename
    Any help on this?
    Last edited by kzatu; Jan 29th, 2008 at 12:05 PM.
    Changes are not permanent, but change is. {Neil Peart}

  2. #2
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: mysql_real_escape_string problem

    This could be a bug. What happens if the path starts with \\n?
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  3. #3

    Thread Starter
    Addicted Member kzatu's Avatar
    Join Date
    Aug 2003
    Location
    Nevada
    Posts
    148

    Re: mysql_real_escape_string problem

    I just tried your suggestion and it does the same thing. I typed
    \\name\share
    and it replaced it with
    \\\r\name\share
    and when I pull it out of the database and print it, it looks like
    \ ame\share
    Changes are not permanent, but change is. {Neil Peart}

  4. #4
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: mysql_real_escape_string problem

    Show us some code: specifically, everything that happens to the value "\\name\share" after the user submits it.

    Escaping \r and \n characters is documented behaviour for this function but it should not be replacing literal \r with literal \r\n. There must either be some other issue with how you are handling the submitted data or the function is buggy.

  5. #5

    Thread Starter
    Addicted Member kzatu's Avatar
    Join Date
    Aug 2003
    Location
    Nevada
    Posts
    148

    Re: mysql_real_escape_string problem

    Hmm. I was trimming the excess fat off of my code so that I could show you the bare essentials of what my code is doing when I stumbled upon a discovery. The problem appears to lie with TinyMCE which is something that I just installed and deployed a few weeks ago.

    So here is the code in its simplest form with its suspected bug.
    Code:
    <?php
      $newcontent=$_POST['newcontent'];
      echo $newcontent;
    ?>
    <HTML>
      <head>
        <script language="javascript" type="text/javascript" src="tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
        <script language="javascript" type="text/javascript">
          tinyMCE.init({
            mode : "textareas",
            theme : "simple"
          });
        </script>
      </head>
      <form method="post" action="test.php">
        <textarea name="newcontent" id="newcontent"><?php echo $newcontent ?></textarea>
        <input class="button" type="submit" name="submit" value="Submit">
      </form>
    </html>
    You can actually go to the live example on TinyMCE's page and witness this bug for yourself at http://tinymce.moxiecode.com/example...p?example=true

    And this appears to be reported as a bug, here http://sourceforge.net/tracker/index...81&atid=635682

    Also, I'll go ahead and mark this thread as closed, but if you want to add something, please do.
    Last edited by kzatu; Jan 30th, 2008 at 01:48 PM.
    Changes are not permanent, but change is. {Neil Peart}

Posting Permissions

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



Click Here to Expand Forum to Full Width