•
•
•
•
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
![]() |
•
•
Join Date: Jul 2008
Posts: 7
Reputation:
Rep Power: 0
Solved Threads: 0
After assigning the string from the db field to a variable such as
Try using the html_entity_decode function like so:
This page will provide reference for this:
http://us3.php.net/manual/en/functio...ity-decode.php
Hope this helps.
$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.
•
•
Join Date: Nov 2007
Posts: 183
Reputation:
Rep Power: 1
Solved Threads: 5
hi
i want to add the fckeditor in a form which is already avaiable.please tell me how to do tat
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', '<p>solomon</p>', 0, '2008-07-19', '01:42:58'),
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>
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', '<p>solomon</p>', 0, '2008-07-19', '01:42:58'),
•
•
Join Date: Jul 2008
Posts: 7
Reputation:
Rep Power: 0
Solved Threads: 0
Ok try the following:
Then create the next page that shows the posts:
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.
php Syntax (Toggle Plain Text)
<?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 Syntax (Toggle Plain Text)
<?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.
Last edited by Evancool : Aug 2nd, 2008 at 6:18 pm. Reason: Fixed typos
![]() |
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- doc root in windows virtual hosting (PHP)
- I'm Gonna Redesign This Website (Website Reviews)
- Fck editer need help (PHP)
- rich editor for cms (ASP.NET)
Other Threads in the PHP Forum
- Previous Thread: pass variable from php to javascript
- Next Thread: [Urgent] Write excel cell values to SQL DB based on cell color?


Linear Mode