Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-28-2007, 05:16 AM   PM User | #1
adammc
New Coder

 
Join Date: Jul 2006
Posts: 71
Thanks: 0
Thanked 0 Times in 0 Posts
adammc is an unknown quantity at this point
Question Decoding html chars for FCKeditor

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 Code:
<p><p>Default text in editor</p></p&gt
I am using this to convert the data and place it in the editors screen:
PHP Code:
$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:

PHP Code:
<p>Default text in editor</p
Can anyone please help?
__________________
Webmaster Tools | Webmaster Forums
adammc is offline   Reply With Quote
Old 02-28-2007, 07:11 AM   PM User | #2
meth
Regular Coder

 
meth's Avatar
 
Join Date: Jan 2003
Posts: 262
Thanks: 0
Thanked 9 Times in 9 Posts
meth is on a distinguished road
This is not the usual output from fckeditor. Your fck configuration is in error.
__________________
I do Web Design, Brisbane based.
More time spent in PHP/MySQL Web Development.
And Search Engine Optimisation takes up the rest of it.
meth is offline   Reply With Quote
Old 02-28-2007, 07:51 AM   PM User | #3
adammc
New Coder

 
Join Date: Jul 2006
Posts: 71
Thanks: 0
Thanked 0 Times in 0 Posts
adammc is an unknown quantity at this point
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 Code:
  <?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:
PHP Code:
 # 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.
__________________
Webmaster Tools | Webmaster Forums
adammc is offline   Reply With Quote
Old 02-28-2007, 10:42 PM   PM User | #4
adammc
New Coder

 
Join Date: Jul 2006
Posts: 71
Thanks: 0
Thanked 0 Times in 0 Posts
adammc is an unknown quantity at this point
I got it sorted using:

PHP Code:
$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

 
?>
__________________
Webmaster Tools | Webmaster Forums
adammc is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:51 AM.


Advertisement
Log in to turn off these ads.