...

View Full Version : Decoding html chars for FCKeditor



adammc
02-28-2007, 05:16 AM
Hi guys,

I am trying to extract data that was placed in my DB by FCKeditor. I am using this to put into the WYSIWYG editor screen.

The content in the DB looks like this:


<p><p>Default text in editor</p></p>


I am using this to convert the data and place it in the editors screen:


$content = "$r[content]";
$pagecontent = html_entity_decode($content);


$oFCKeditor = new FCKeditor("$_GET[page]");
$oFCKeditor->BasePath = '../../fckeditor/';
$oFCKeditor->Value = "$pagecontent";


Its almost getting it in the right format, howver I am left with this:


<p>Default text in editor</p>

Can anyone please help?

meth
02-28-2007, 07:11 AM
This is not the usual output from fckeditor. Your fck configuration is in error.

adammc
02-28-2007, 07:51 AM
I got it to display corrently, not sure which of my changes worked LOL

Does anyone use FCKeditor or anything similiar?
I am struggling to get this working, I am thinking I am going about this the wrong way ??

Pages_Table
page_id | page_name

Content Table
content_id | page_id | content

In my CMS I have a page that I insert entries into the pages_table. (pages on the website that I want to use the FCKeditor on.

I then added a page that has a dropdown list, this pulls a list of pagenames from the pages table getting the 'page_id'. The form sends you to the next page with the FCKeditor, in effect pulling the data / html from the content_table for the relevant 'page_id'

Ok...
So what the problem is if there isnt an entry for the page_id, nothing is displayed?

Another problem I am sure I will face is to Update or insert :(



<?php

$query = mysql_query("SELECT * FROM CMS_content WHERE page_id='$_GET[page]'");
while($r = mysql_fetch_assoc($query))
{

?>

<br /><br />

<form action="pages-edit-process.php" method="post">

<?php
$content = "$r[content]";

// Adjust HTML Tags
$pagecontent = html_entity_decode ($content);

$oFCKeditor = new FCKeditor("$_GET[page]");
$oFCKeditor->BasePath = '../../fckeditor/';
$oFCKeditor->Value = "$pagecontent";
$oFCKeditor->Width = '100%' ;
$oFCKeditor->Height = '300' ;
$oFCKeditor->Create();
?>

<br / >
<input type="submit" value="Submit">
</form>

</div>

<?
} // end of while statemnt
?>



The code that processes this:


# this is processed when the form is submitted
# back on to this page (POST METHOD)
if ($REQUEST_METHOD=="POST") {


# setup SQL statement
$SQL = " UPDATE CMS_content SET content ='$postedValue' WHERE page_id='$sForm' ";


#execute SQL statement
$result = mysql_db_query($db,"$SQL",$cid);

# check for error
if (!$result) { echo("ERROR: " . mysql_error() . "\n$SQL\n"); }

echo ("<P align=center><font class=menu><b>The new data has been added!</b></font></P>\n");

}

mysql_close($cid);



Can anyone make any sense of this?
Any advice would be GREATLY appreciated.

adammc
02-28-2007, 10:42 PM
I got it sorted using:



$query = ("SELECT * FROM CMS_content WHERE page_id='$_GET[page]'");
$result = mysql_db_query($db,"$query",$cid);

if (!$result) die("Query Failed.");

if (mysql_num_rows($result) > 0) {



// if it found a result
echo "results found ";

$query = mysql_query("SELECT * FROM CMS_content WHERE page_id='$_GET[page]'");
while($r = mysql_fetch_assoc($query))
{

?>

<br /><br />

<form action="pages-edit-process.php?m=update" method="post">

<?php
$content = "$r[content]";

// Adjust HTML Tags
$pagecontent = html_entity_decode ($content);

$oFCKeditor = new FCKeditor("$_GET[page]");
$oFCKeditor->BasePath = '../../fckeditor/';
$oFCKeditor->Value = "$pagecontent";
$oFCKeditor->Width = '100%' ;
$oFCKeditor->Height = '300' ;
$oFCKeditor->Create();
?>

<br / >
<input type="submit" value="Submit">
</form>

</div>

<?
} // end of while statemnt


} else {

/**************

If no data exists for the page_id - Show modified form.
Then set notice as different process page method - update / Insert

********************/

echo "no result ";

?>
<form action="pages-edit-process.php?m=insert" method="post">

<?php


/**************

Begin FCKeditor Code / Settings

********************/

$oFCKeditor = new FCKeditor("$_GET[page]");
$oFCKeditor->BasePath = '../../fckeditor/';
$oFCKeditor->Value = "blank";
$oFCKeditor->Width = '100%' ;
$oFCKeditor->Height = '300' ;
$oFCKeditor->Create();
?>

<br / >
<input type="submit" value="Submit">
</form>

<?
} // end of if else

?>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum