Re: Database integration

  •  03-18-2011, 8:14 AM

    Re: Database integration

    Dear pbrad,
     
    Sql Server example:
    <?php include_once("cuteeditor_files/include_CuteEditor.php") ; ?>
    <html>
    <head>
    </head>
    <body>
    <form name="theForm" action="11.php?postback=true" method="post"><?php
    function getData()
    {
        $conn=mssql_connect("127.0.0.1","cute","cute");
     $db=mssql_select_db("cuteeditortest", $conn);
     $sql = "SELECT ID, content FROM acid";
     $res = mssql_query($sql);
     $row = mssql_fetch_array($res); 
        $data = $row['content'];
      //echo("<script type='text/javascript'>");
      //echo("alert('$data')");
      //echo("</script>");
     mssql_close();
     return $data;
    }
    function writeData($content)
    {
     $conn=mssql_connect("127.0.0.1","cute","cute");
     $db=mssql_select_db("cuteeditortest", $conn);
     $sql = "INSERT INTO acid(id, content) values ('55','$content')"; 
     $res = mssql_query($sql);
     mssql_close();
    }
    ?>
    <?php
    $editor=new CuteEditor();
    $editor->ID="Editor1";
    $editor->UseHTMLEntities=false;
    $editor->EditCompleteDocument=true;
    if (@$_GET["postback"]!="true")
    {
     $editor->Text = getData();
     $editor->Draw();
    }
    else
    {
     writeData($_POST["Editor1"]);
     $editor->Text = $_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> 
    MySQL example:
    <?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>
     Thank you for asking
View Complete Thread