User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 426,520 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 1,930 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 648 | Replies: 7
Reply
Join Date: Nov 2007
Posts: 183
Reputation: lydia21 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 5
lydia21 lydia21 is offline Offline
Junior Poster

fck editor

  #1  
Jul 19th, 2008
hi
when the user enter the data i tried it storing in the db and its working.
the datas are getting stored as
<p>This is some <strong>sample text</strong>. You are using</p>
when i display i want to display in html format
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jul 2008
Posts: 7
Reputation: Evancool is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Evancool Evancool is offline Offline
Newbie Poster

Re: fck editor

  #2  
Jul 19th, 2008
After assigning the string from the db field to a variable such as

$row = mysql_fetch_array($result);
$var = $row["field"];

Try using the html_entity_decode function like so:

$htmlvar = html_entity_decode($var);
echo $htmlvar;

This page will provide reference for this:

http://us3.php.net/manual/en/functio...ity-decode.php

Hope this helps.
Reply With Quote  
Join Date: Nov 2007
Posts: 183
Reputation: lydia21 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 5
lydia21 lydia21 is offline Offline
Junior Poster

Re: fck editor

  #3  
Jul 19th, 2008
thanks for ur help.it was really useful
Reply With Quote  
Join Date: Nov 2007
Posts: 183
Reputation: lydia21 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 5
lydia21 lydia21 is offline Offline
Junior Poster

Re: fck editor

  #4  
Jul 19th, 2008
hi
i want to add the fckeditor in a form which is already avaiable.please tell me how to do tat

<?php
include_once("fckeditor/fckeditor.php") ;
if ( isset( $_POST ) )
$postArray = &$_POST ;// 4.1.0 or later, use $_POST
else
$postArray = &$HTTP_POST_VARS ;
foreach ( $postArray as $sForm => $value )
{
$title=$_REQUEST["title"];
if ( get_magic_quotes_gpc() )
{
$postedValue = htmlspecialchars( stripslashes( $value ) ) ;
}
else
{
$postedValue = htmlspecialchars( $value ) ;
}
//db connections
mysql_query("INSERT INTO article(ar_title,ar_desc)values('$title','$postedValue')");
}
?>

///html part
<form action="postarticle.php" method="post">
<input type="test" name="title">
<?php
$oFCKeditor = new FCKeditor('FCKeditor1') ;
$oFCKeditor->BasePath = 'http://www.careerglitters.com/fckeditor/' ;
$oFCKeditor->Value = '' ;
$oFCKeditor->Create() ;
?>
<br>
<input type="submit" value="Submit">
</form>
i want to do something like this but datas are getting inserted twice in my db
eg:
where sol i entered in my text box
and solomon in my editor.when submit button is clicked datas are getting inserted twise like the below eg
(55, 'sol', 'sol', 0, '2008-07-19', '01:42:58'),
(56, 'sol', '&lt;p&gt;solomon&lt;/p&gt;', 0, '2008-07-19', '01:42:58'),
Reply With Quote  
Join Date: Jul 2008
Posts: 7
Reputation: Evancool is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Evancool Evancool is offline Offline
Newbie Poster

Re: fck editor

  #5  
Jul 20th, 2008
Let me do some research on this, what version of FCKEditor and PHP are you using? The code example above looks really old.
Reply With Quote  
Join Date: Nov 2007
Posts: 183
Reputation: lydia21 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 5
lydia21 lydia21 is offline Offline
Junior Poster

Re: fck editor

  #6  
Jul 21st, 2008
i am using fck editor2.6.2-version,php version 5
Reply With Quote  
Join Date: Jul 2008
Posts: 7
Reputation: Evancool is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Evancool Evancool is offline Offline
Newbie Poster

Re: fck editor

  #7  
Jul 29th, 2008
sorry I kinda dropped the ball on this one, been too busy with work. anyone else can chime in when they want.
Reply With Quote  
Join Date: Jul 2008
Posts: 7
Reputation: Evancool is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Evancool Evancool is offline Offline
Newbie Poster

Re: fck editor

  #8  
Aug 2nd, 2008
Ok try the following:

  1.  
  2. <?php
  3.  
  4. # Filename: fcktest.php
  5.  
  6. if($_POST['submitted'] == 1) { # THIS IS THE RESULT AFTER FORM SUBMIT
  7.  
  8. mysql_connect("localhost", "root", ""); # change this to your db connect
  9. mysql_select_db("test"); # change this to your db
  10.  
  11. $title = mysql_real_escape_string(stripslashes($_POST["title"]));
  12. $content = mysql_real_escape_string(htmlentities(stripslashes($_POST["postText"])));
  13.  
  14. mysql_query("INSERT INTO article (ar_title,ar_desc) VALUES ('".$title."','".$content."')") or die("Error: ".mysql_error());
  15.  
  16. print 'post submitted.';
  17. print '<br /><br />';
  18. print '<a href="fcktestdb.php">Click here</a> to view on the next page.';
  19. print '<br /><br />';
  20. print '<a href="fcktest.php">Click here</a> to create a new post.';
  21. }
  22.  
  23. else { # THIS IS ON THE FORM PAGE BEFORE SUBMIT
  24.  
  25. include_once("fckeditor/fckeditor.php");
  26.  
  27. print '<form action="" method="post">';
  28. print '<input type="text" name="title">';
  29.  
  30. $oFCKeditor = new FCKeditor('postText') ;
  31. $oFCKeditor->BasePath = '/path/fckeditor/' ; # change this to your path
  32. $oFCKeditor->Value = '' ;
  33. $oFCKeditor->Create() ;
  34.  
  35. print '<br />';
  36. print '<input type="hidden" value="1" name="submitted" />';
  37. print '<input type="submit" value="Submit" />';
  38. print '</form>';
  39. }
  40.  
  41. ?>
  42.  

Then create the next page that shows the posts:

  1. <?php
  2.  
  3. # Filename: fcktestdb.php
  4. # SHOW THE POSTED DATA FROM THE DATABASE
  5.  
  6. mysql_connect("localhost", "root", ""); # change this to your db connect
  7. mysql_select_db("test"); # change this to your db
  8.  
  9. $query = 'SELECT * FROM article';
  10. $result = mysql_query($query);
  11.  
  12.  
  13. $count = 0;
  14.  
  15. while($rows = mysql_fetch_array($result)) {
  16.  
  17. $count++;
  18. $title = stripslashes($rows["ar_title"]);
  19. $post = html_entity_decode(stripslashes($rows["ar_desc"]));
  20.  
  21. print 'Post '.$count;
  22. print '<br /><br />';
  23. print 'Title: '.$title;
  24. print '<br /><br />';
  25. print 'Posted Content: '.$post;
  26. print '<br /><br />';
  27.  
  28. }
  29.  
  30. ?>
  31.  


I think what was happening was that since you used a foreach it may have looped through twice on the post vars. Also, since you were on PHP5 I removed some of the extra code such as HTTP_POST_VARS and magic quotes condition statements.

Hope this helps.
Last edited by Evancool : Aug 2nd, 2008 at 6:18 pm. Reason: Fixed typos
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb PHP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 6:21 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC