Results 1 to 6 of 6

Thread: RTE preloaded html content as a variable with php

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

    Default RTE preloaded html content as a variable with php

    Hi there,

    I am trying to change the preload html content, and use the content of a variable instead. When I declare the variable in the page it works :

    <?php
    $test="<b>hello</b> world";
    ?>
    <script language="JavaScript" type="text/javascript">
    <!--
    writeRichText('rte1', '<?php echo $test;?>', 520, 400, true, false);

    this works fine, the RTE shows : hello world , in the text box

    but if my content comes from my MySql data base :

    <?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']; //this contains "<b>hello</b> world"
    ?>
    <script language="JavaScript" type="text/javascript">
    <!--
    writeRichText('rte1', '<?php echo $test;?>', 520, 400, true, false);
    //-->
    </script>

    the RTE doesn't even open.

    What do I do wrong? Can someone help?
    thank you
    lolo

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

    Default

    It may be something with the SQL query. Try simply echoing $test outside of the RTE and see if it echos. If not, you may need to change the mysql_fetch_assoc to mysql_fetch_array or something like that.

    Hope this helps.
    "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
    Jan 2007
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    The problem comes from mysql and the fact that the RTE actually adds some &#37;0D%0A at the end of the rte1 variable value. Means that is works if I manually enter the html code in my database, but if I use INSERT and $_GET['rte1'] to fill my database there are 2 extra blank line that are the cause of the problem (I think), and when I echo it with php these 2 line don't show.
    Someone knows how I can get rid of these %0D%0A before filling the db?

    lolo

    (thanks testing site)

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

    Default

    Please don't cross-post.

    I've answered in that thread; had I seen this one first, I would have answered here, since it is more appropriate.
    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!

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

    Default

    perfect , sorry for the cross post
    Last edited by lolo; 01-14-2007 at 09:41 PM.

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

    Default

    thanx again master!

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
  •