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

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/function.html-entity-decode.php

Hope this helps.

thanks for ur help.it was really useful

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'),

Let me do some research on this, what version of FCKEditor and PHP are you using? The code example above looks really old.

i am using fck editor2.6.2-version,php version 5

sorry I kinda dropped the ball on this one, been too busy with work. anyone else can chime in when they want.

Ok try the following:

<?php
	
	# Filename: fcktest.php
	
	if($_POST['submitted'] == 1) { # THIS IS THE RESULT AFTER FORM SUBMIT
		
		mysql_connect("localhost", "root", ""); # change this to your db connect
		mysql_select_db("test"); # change this to your db
		
		$title = mysql_real_escape_string(stripslashes($_POST["title"]));
		$content = mysql_real_escape_string(htmlentities(stripslashes($_POST["postText"])));
		
		mysql_query("INSERT INTO article (ar_title,ar_desc) VALUES ('".$title."','".$content."')") or die("Error: ".mysql_error());
		
		print 'post submitted.';		
		print '<br /><br />';
		print '<a href="fcktestdb.php">Click here</a> to view on the next page.';
		print '<br /><br />';
		print '<a href="fcktest.php">Click here</a> to create a new post.';
	}
	
	else { # THIS IS ON THE FORM PAGE BEFORE SUBMIT
		
		include_once("fckeditor/fckeditor.php");
		
		print '<form action="" method="post">';
		print '<input type="text" name="title">';
	
		$oFCKeditor = new FCKeditor('postText') ;
		$oFCKeditor->BasePath = '/path/fckeditor/' ; # change this to your path
		$oFCKeditor->Value = '' ;
		$oFCKeditor->Create() ;
		
		print '<br />';
		print '<input type="hidden" value="1" name="submitted" />';
		print '<input type="submit" value="Submit" />';
		print '</form>';
	}
	
?>

Then create the next page that shows the posts:

<?php

	# Filename: fcktestdb.php
	# SHOW THE POSTED DATA FROM THE DATABASE
	
	mysql_connect("localhost", "root", ""); # change this to your db connect
	mysql_select_db("test"); # change this to your db
	
	$query = 'SELECT * FROM article';
	$result = mysql_query($query);
	
	
	$count = 0;
	
	while($rows = mysql_fetch_array($result)) {
		
		$count++;
		$title = stripslashes($rows["ar_title"]);
		$post = html_entity_decode(stripslashes($rows["ar_desc"]));
		
		print 'Post '.$count;
		print '<br /><br />';
		print 'Title: '.$title;
		print '<br /><br />';
		print 'Posted Content: '.$post;
		print '<br /><br />';
		
	}

?>

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.

Lydia, did this work or not?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.