Results 1 to 3 of 3

Thread: How to remove %0D%0A before inserting $_GET['rte1'] in my database ?

  1. #1
    Join Date
    Jan 2007
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question How to remove %0D%0A before inserting $_GET['rte1'] in my database ?

    hi there,

    I first reported this problem on the php forum but I think it is a mysql problem.

    I try to save the content of $_GET['rte1'] (once the form as been sumited) into my mysql database.
    the INSERT works but since the RTE adds some %0D%0A at the end of the $_GET['rte1'] value, when I try to reuse that content as the preload html code of the RTE, the RTE doesn t work any more. (the code bellow works only if I "manually" insert some html code in my database, when I use INSERT it adds 2 blank lines)

    <?php
    $sql = "SELECT test FROM test";
    $req=mysql_query($sql) or die('Erreur SQL !'.$sql.'<br>'.mysql_error());
    $data=mysql_fetch_assoc($req);
    $test=$data['test'];
    ?>
    <script language="JavaScript" type="text/javascript">
    <!--
    writeRichText('rte1', '<?php echo $test;?>', 520, 400, true, false);
    //-->
    </script>

    Someone knows how I can get rid of these %0D%0A before filling the db?

    thank you
    lolo

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Just $test = str_replace(array("\n", "\r"), array('\n', '\r'), $data['test']);
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Jan 2007
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    perfect!
    Last edited by lolo; 01-14-2007 at 09:39 PM.

Bookmarks

Posting Permissions

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