Advanced Search

Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Rich Text Editor and PHP

  1. #1
    Join Date
    Oct 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Rich Text Editor and PHP

    1) Script Title: Rich Text Editor (for textareas)

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...itor/index.htm

    3) Describe problem:

    I am trying to enable users to update sections of the site easily. I have managed to get the RTE set up so that it can submit data into the database. However, when I try and retrieve it to edit it the RTE just dissapears.
    How can I sort this out?

  2. #2
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    you may have to do addslashes or htmlentities (<spelling?) to fix that problem. That is if it only dissapears when anything with single quotes is extracted from the db then there's your problem, and the above to PHP functions should fix it.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  3. #3
    Join Date
    Oct 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I found this code on another website that apparently fixes this problem, but I am unsure of how to incorporate it. Here is what I found:

    PHP Code:
    function rteSafe($strText) { 
       
    //returns safe code for preloading in the RTE 
       
    $tmpString $strText
        
       
    //convert all types of single quotes 
       
    $tmpString str_replace(chr(145), chr(39), $tmpString); 
       
    $tmpString str_replace(chr(146), chr(39), $tmpString); 
       
    $tmpString str_replace("'""'"$tmpString); 
        
       
    //convert all types of double quotes 
       
    $tmpString str_replace(chr(147), chr(34), $tmpString); 
       
    $tmpString str_replace(chr(148), chr(34), $tmpString); 
    //   $tmpString = str_replace("\"", "\"", $tmpString); 
        
       //replace carriage returns & line feeds 
       
    $tmpString str_replace(chr(10), " "$tmpString); 
       
    $tmpString str_replace(chr(13), " "$tmpString); 
        
       return 
    $tmpString
    }
    //function rteSafe($strText) 

    use the above function, which basically replaces problematic characters from the content before being input in the x.html variable


    use it like this :
    PHP Code:
    <rteSafe
    Can anyone tell me how I would set up this code, ie where I would put it. Thanks

  4. #4
    Join Date
    Nov 2006
    Location
    Virginia
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I've hooked up RTE to add content to my database.

    Question is, How do I $_GET the data out so that it can be editted? What do I use? I'm new at this so I'm not sure.

    Thanks in advance.

    M-
    Last edited by MD version 1.0; 11-22-2006 at 04:11 PM.

  5. #5
    Join Date
    Oct 2008
    Location
    Maryland
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Submit data into the database

    How did you get it to submit to the database? Would you mind posting some code.

  6. #6
    Join Date
    Jul 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up

    Quote Originally Posted by MD version 1.0 View Post
    I've hooked up RTE to add content to my database.

    Question is, How do I $_GET the data out so that it can be editted? What do I use? I'm new at this so I'm not sure.

    Thanks in advance.

    M-

    Because it's a lot of data that might be in the post, use the POST method ... then the post will be hidden in a POST variable instead of using the GET method and having everything urlencoded in the address bar

    Code:
    <form method='post' action=''>
    <textarea name='content'><?php echo rteSafe($content_string); ?>here</textarea>
    <br>
    <input type='submit' name='submit' value='Submit'>
    </form>
    <?php
    if (isset($_POST['submit'])){
      //write $content string to database
    }
    ?>
    Does this help you? I don't mind helping with this topic as I have been working on these issues for a while.


    Mike
    Last edited by thetestingsite; 07-18-2009 at 01:32 AM. Reason: removed signature.

  7. #7
    Join Date
    Apr 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by mikethestone View Post
    Because it's a lot of data that might be in the post, use the POST method ... then the post will be hidden in a POST variable instead of using the GET method and having everything urlencoded in the address bar

    Code:
    <form method='post' action=''>
    <textarea name='content'><?php echo rteSafe($content_string); ?>here</textarea>
    <br>
    <input type='submit' name='submit' value='Submit'>
    </form>
    <?php
    if (isset($_POST['submit'])){
      //write $content string to database
    }
    ?>
    Does this help you? I don't mind helping with this topic as I have been working on these issues for a while.


    Mike

    Hi,

    Use this code in your php
    $content_string=addslashes(preg_replace('`[\r\n]`','',$content_string));


    Eddie

  8. #8
    Join Date
    Apr 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Problem

    In internet explorer when I type:

    <div id="4"></div>


    Then the "" disappears and I get

    <div id=4></div>


    Is there a way that I can keep these "" qoutes with div and also class ?

    thx in advance!

  9. #9
    Join Date
    May 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    1) Script Title: Rich Text Editor (for textareas)

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...itor/index.htm

    3) Describe problem:

    I am trying to enable users to update sections of the site easily. I have managed to get the RTE set up so that it can submit data into the database. However, when I try and retrieve it to edit it the RTE just dissapears.
    How can I sort this out?

    Hi Friends,even am facing same problem as above,i dont no what to do any one can help me

  10. #10
    Join Date
    Jul 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    <tr>
    <td>
    </td>
    <td>
    <div style="padding-left: 0px;"><textarea name="spaceaboutmeTemp" id="textAreaSpaceAboutMe" cols="10" rows="6" style="width: 63%; display: none;">{user.space.aboutme}</textarea>
    </div>
    </td>
    </tr>
    <tr>
    <td>
    </td>
    <td>
    <script language="JavaScript" type="text/javascript">
    var s = document.getElementById('textAreaSpaceAboutMe').value;
    writeRichText('spaceaboutme', s, 550, 150, true, false);
    </script>
    </td>
    </tr>
    *see this it should help
    I am creating a new textarea that is hidden and in that textarea is going the php post. After this with javascript I am giving the content from the hidden textarea to the rich text editor and it's workint in this way.

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
  •