• Howdy! Welcome to our community of more than 130.000 members devoted to web hosting. This is a great place to get special offers from web hosts and post your own requests or ads. To start posting sign up here. Cheers! /Peo, FreeWebSpace.net
managed wordpress hosting

TinyMCE Integration

Dan

Bullah
NLC
Hey folks.

I downloaded TinyMCE and followed the instructions to install and integrate it into a php web page. All fine and dandy.
I also figured out how to get the info to the page by adding the following to the section where I wanted the content to show:

PHP:
<?php
echo(stripslashes($_POST['content']));
?>

However, when I refresh that page I get the following:

Notice: Undefined index: content in C:\wamp\www\site\index.php on line 87

I also would like for the content that was placed into the editor to remain there so it can be edited in future without losing data. Something like what Joomla does? Can anyone please give me a simple english lesson on this?
I have tried the TinyMCE support forums but was told to ask elsewhere.
I have also searched Google but to no avail.

I know my options are:

1. Have the editor submit the content to MySQL and have the editor save the changes within itself somehow.
2. Submit the data to a flat file and have that data sent to the targetted area on the page.

Any ideas? Suggestions?

Thanks in advance.
 
The first option would be your best bet, flat-file would be risky. Take a leaf out of WordPress' book.
 
Thanks Dynash.

I have created the DB and the row I want to use to store content and send it to the index page.

The Database:

PHP:
CREATE TABLE `content` (
  `indexcontent` int(10) unsigned default NULL,
  PRIMARY KEY  (`indexcontent`)
);
INSERT INTO `content` (`indexcontent`) VALUES ('This is default text from the database.');

I am new to MySQL really so not sure if that's even right. Although it imports ok without errors.

Here is the part in the TinyMCE code that sends the content to the database, or so I hoped:

PHP:
<form method="post" action="../index.php">
	<textarea name="content" style="width:500px; height: 300px;">Content	</textarea><br />
	<input type="submit" name="submit" value="Post">
</form>

and the part in index.php that collects from the DB, or so I would have hoped:

PHP:
<?php
echo(stripslashes($_POST['indexcontent']));
?>

I did all this and it won't work. Still getting the same error as before.
If anyone can help solve this I would really appreciate it.
 
Where you have $_POST, all that does it take the information (In this case, content) from the form after it is submitted. It doesn't stay around for long. What you need to do is create two separate SQL statements in PHP (INSERT & SELECT) in order to store and retrieve the information from your database when needed.

This SQL table would be better:

Code:
CREATE TABLE IF NOT EXISTS `content` (
  `indexcontent` varchar(255) NOT NULL,
  PRIMARY KEY (`indexcontent`)
);


Then where you get the info from $_POST, do something that is close to this:

PHP:
<?php

mysql_connect('localhost', 'root', 'root') or die (mysql_error());
mysql_select_db('db') or die (mysql_error());

$Content = stripslashes($_POST['content']); // 'content' because you have that as the name="" in the form.
$SendContent = mysql_query("INSERT INTO `content` (`indexcontent`) VALUES (`$Content`)"); // now that should store your info into the database, use some if statements to give feedback of failed/success.

$GetContent = mysql_query("SELECT `indexcontent` FROM `content`");

foreach ( $GetContent as $Contents) {
  echo "$Contents\n";
}

?>

You'll have to check if this works for you, it was just a quick rep of what you should be doing, nothing "great".
 
Nah.
Getting the following errors:

PHP:
Notice: Undefined index: content in C:\wamp\www\site\admin\editindex.php on line 59

Warning: mysql_query() [function.mysql-query]: Access denied for user 'SYSTEM'@'localhost' (using password: NO) in C:\wamp\www\site\admin\editindex.php on line 60

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in C:\wamp\www\site\admin\editindex.php on line 60

Warning: mysql_query() [function.mysql-query]: Access denied for user 'SYSTEM'@'localhost' (using password: NO) in C:\wamp\www\site\admin\editindex.php on line 62

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in C:\wamp\www\site\admin\editindex.php on line 62

Warning: Invalid argument supplied for foreach() in C:\wamp\www\site\admin\editindex.php on line 64

Don't know where SYSTEM is coming from.
 
do you have the mysql connect statement built properly man?

PHP:
$link = mysql_connect('HOSTNAME HERE', 'MYSQL USER HERE', 'MYSQL PASSWORD HERE');
mysql_select_db('DATABASE NAME HERE',$link) or die('Could not connect to database<br/><br/><strong>MySQL Error:</strong><br/>'.mysql_error());
 
do you have the mysql connect statement built properly man?

PHP:
$link = mysql_connect('HOSTNAME HERE', 'MYSQL USER HERE', 'MYSQL PASSWORD HERE');
mysql_select_db('DATABASE NAME HERE',$link) or die('Could not connect to database<br/><br/><strong>MySQL Error:</strong><br/>'.mysql_error());

Hey Justin,

What I have mate is the database info in a config file. So at the top of each page that needs to connect I have
Code:
include_once 'includes/config.php' ;

Not sure if that's the correct way or not.

I know I am known for forking applications and releasing them as my own. I am over that. I want to make an honest go at something. I am almost there. Just need to get TinyMCE working.
 
Last edited:
Back
Top