Re: saved html in mysql db displays as plain text when retrieved

  •  09-06-2010, 3:29 PM

    Re: saved html in mysql db displays as plain text when retrieved

    Dear mp5802,
     
    The following code shows how to read write content between cuteeditor and mysql: 

    <?php include_once("cuteeditor_files/include_CuteEditor.php") ; ?>
    <html>
    <head>
    </head>
    <body>
    <form name="theForm" action="1.php?postback=true" method="post"><?php
    function getData()
    {
     $cnx = mysql_connect('localhost','root','');
     mysql_select_db('cuteeditortest');
     $records = @mysql_query('SELECT ID, content FROM acid');
     if (!$records) {
      return "data is empty";
     }
     if ($record = mysql_fetch_array($records)) {
      $id   = $record['ID'];
      $content = $record['content'];
      return $content;
     }
    }
    function writeData($content)
    {
     $connect = @mysql_connect( "localhost", "root", "" );
     if ( ! $connect ) {
      die( "Couldn't connect to MySQL: ".mysql_error() );
     }
     $db = "cuteeditortest";
     @mysql_select_db( $db ) or die ( "Couldn't open $db: ".mysql_error() );
     $sql = "INSERT INTO acid( id, content ) values ('55','$content')";
     mysql_query( $sql, $connect ) or die ( "INSERT error: ".mysql_error() );
     mysql_close( $connect );
    }
    ?> <?php
    $editor=new CuteEditor();
    $editor->ID="Editor1";
    $editor->EditCompleteDocument=true;
    if (@$_GET["postback"]!="true")
    {
     $editor->Text = getData();
     $editor->Draw();
    }
    else
    {
     writeData($_POST["Editor1"]);
     $editor->Draw();
    }
    $editor=null;
    //use $_POST["Editor1"]to retrieve the data
    ?> <textarea name="textbox1" rows="2" cols="20" id="textbox1"
     style="font-family: Arial; height: 250px; width: 730px;">
    <?php echo @stripslashes($_POST["Editor1"]) ;?>
                </textarea></form>
    </body>
    </html>

    Thanks for asking
View Complete Thread