Forum Moderators: coopster

Message Too Old, No Replies

Decoding html chars for FCKeditor

         

adammc

5:17 am on Feb 28, 2007 (gmt 0)

10+ Year Member



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:
[php]
<p><p>Default text in editor</p></p>
[/php]

I am using this to convert the data and place it in the editors screen:
[php]
$content = "$r[content]";
$pagecontent = html_entity_decode($content);

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

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

[php]<p>Default text in editor</p>[/php]

Can anyone please help?

adammc

7:50 am on Feb 28, 2007 (gmt 0)

10+ Year Member



I gotthe code to display, I really dont know what I changed ot fix it though :(

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]
<?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
?>
[/php]

The code that processes this:
[php]
# 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);
[/php]

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

Scally_Ally

8:55 am on Feb 28, 2007 (gmt 0)

10+ Year Member



I have used FCK before and it was a bit 'fiddly' to get workin in the first place, although i didnt have to decode stuff to get it to display in the editor - it just displayed in there straight away. The only problem that i had was line breaks seeming to break the editor, so on initialisation i had something like this:

include("../FCKeditor/fckeditor.php") ;
$myrow[shortdesc] = ereg_replace("\n", "", $myrow[shortdesc]);
$myrow[shortdesc] = ereg_replace("\r", "", $myrow[shortdesc]);
$oFCKeditor = new FCKeditor('shortdesc');
$oFCKeditor->BasePath = '/FCKeditor/';
$oFCKeditor->Value = $myrow[shortdesc];
$oFCKeditor->Width = '100%' ;
$oFCKeditor->Height = '400' ;
$oFCKeditor->Create();

and then when saving it into the db i was using just add slashes - this seemed to work for me
shortdesc='".addslashes($_POST[shortdesc])."',

Hope this helps
Ally

adammc

10:40 pm on Feb 28, 2007 (gmt 0)

10+ Year Member



HI Scally,

Thanks for the info, much appreciated :)