using fck editor to update mysql tables

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
drygoni
Forum Newbie
Posts: 4
Joined: Sat Oct 20, 2007 4:25 am

using fck editor to update mysql tables

Post by drygoni »

Everah | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hello,

i downloaded and installed fckeditor into my website yesterday and i am using it to post blogs on to my website. I can successfully create new posts and they display correctly..
I also want to use it to edit existing posts in my database.
I can get fck editor to display my posts that i want to edit but i cannot get it to update my database, it appears to work but when i look at the posts i have edited, it hasn't updated at all.
If anyone has any ideas, i would be very, VERY pleased to hear them!
I am using PHP and i'm using a Mysql database..
my current code looks something like this.

Code: Select all

<?php
include("fckeditor.php");
session_start();
//insert my db connection details
include ("vars.inc");

if(isset($_POST['theComment'])){
$query = "UPDATE article SET name='".$_SESSION[logname]."',title='".$_POST['title']."',comments='".$_POST[comment]."'
where artid ='".$_GET['aid']."'";
if(!mysqli_query($cxn,$query)){
echo mysqli_error($cxn);
}else{
header("location:main.php");
exit;
}
}
?>
I then call the original post through by using this:

Code: Select all

<?php
$query1 = "select * from article where artid ='".$_GET['aid']."'";
$edit_blog = mysqli_query($cxn, $query1) or die (mysqli_error($cxn));
$blog_result = mysqli_fetch_assoc($edit_blog);
?>
And then my fckeditor is set up as follows:

Code: Select all

<?php
$content = $blog_result['comments'];
$sBasePath = $_SERVER['PHP_SELF'] ;
$sBasePath = substr( $sBasePath, 0, strpos( $sBasePath, "_samples" ) ) ;
$oFCKeditor = new FCKeditor('comment') ;
$oFCKeditor->BasePath = $sBasePath ;
$oFCKeditor->Width = '100%' ;
$oFCKeditor->Height = '300' ;
$oFCKeditor->Value = $content;
$oFCKeditor->Create() ;
?>
Thanks in advance...


Everah | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Understand that FCKEditor is a JAvascript front end GUI editor. The actual editing will be done when the form is submitted and it presented to the database via an UPDATE query.

You may want to try loading your pages with error reporting set to E_ALL and display errors on. Add this to each of your pages in this app that you are testing:

Code: Select all

<?php
ini_set('error_reporting', E_ALL);
ini_set('display_errors', 1);
?>
Then run the script again and see if there are any errors thrown.
drygoni
Forum Newbie
Posts: 4
Joined: Sat Oct 20, 2007 4:25 am

Post by drygoni »

Thanks for your reply,

I added the code but I still don't get any error messages... It looks like the update works but then when I check it has still hasn't updated!

any other suggestions?

Thanks
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Before sending it to the database, can you do a var_dump() on it to see what the database is seeing?
User avatar
Mordred
DevNet Resident
Posts: 1579
Joined: Sun Sep 03, 2006 5:19 am
Location: Sofia, Bulgaria

Post by Mordred »

Check what's in the db win phpmyadmin. Maybe you have http caching issues.
drygoni
Forum Newbie
Posts: 4
Joined: Sat Oct 20, 2007 4:25 am

Post by drygoni »

Ok, i'll have a go..

In the meantime, the error_log states this, if this is any help? - you'll have to excuse me, i'm fairly new to PHP!

Code: Select all

[22-Oct-2007 10:55:21] PHP Notice:  Use of undefined constant logname - assumed 'logname' in C:\apache\htdocs\overspecific\blogs\Admin\edit.php on line 11

[22-Oct-2007 10:55:21] PHP Notice:  Undefined index:  aid in C:\apache\htdocs\overspecific\blogs\Admin\edit.php on line 12

[22-Oct-2007 10:57:34] PHP Notice:  Use of undefined constant logname - assumed 'logname' in C:\apache\htdocs\overspecific\blogs\Admin\edit.php on line 11

[22-Oct-2007 10:57:34] PHP Notice:  Undefined index:  aid in C:\apache\htdocs\overspecific\blogs\Admin\edit.php on line 12
Thanks

Glenn
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Those errors should show to the screen if you have display_errors turned on.

Also, if you look in the code at the line specified by each of those errors you will see what the PHP engine is seeing and why it is throwing those notices.
drygoni
Forum Newbie
Posts: 4
Joined: Sat Oct 20, 2007 4:25 am

Post by drygoni »

Thanks so much for your help, I checked the code and found my mistakes and now it works a treat...

Never even thought to use the error log.. That could have saved me a lot of time over the last few weeks!

Thanks again...
Post Reply