HELP! I lost count of how many editors I tried! I don't understand why non of them work.
I'm trying this editor
very simple. but when I type words in the textarea and click submit nothing is saved in the DB..empty that's what I get.
all I want is a textarea with a bold, underline and italic buttons. user types, makes things bold or whatever, click save and it's saved as "<b> blah </b>" or "[b.]blah[/b.]" (don't understand the difference between html and bb) in my DB. then I display it somewhere and the user sees "blah"

can someone help me with this?

here's my code

<?php if (isset($_GET['...'])&&isset($_GET['..'])) {?>
     <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<?php echo'   <input type="text" id="title" name="title" />';?>
<script src="new/nicEdit.js" type="text/javascript"></script>
<script type="text/javascript">
bkLib.onDomLoaded(function() {
	new nicEditor({buttonList : ['fontSize','bold','italic','underline','strikeThrough','subscript','superscript','html','image']}).panelInstance('area4');
	     <textarea cols="50" id="area4" name="area4"></textarea> 
	  <input type="submit" name="submit" value="save" />

 if (isset($_POST['submit'])) {
	if (isset($_POST['title']) && isset($_POST['area4')) {			
		$title = $_POST['title'];
		$content = $_POST['area4'];
		$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD, TRUE)or die('Error connecting to MySQL server.');	   
		mysql_selectdb(DB_NAME,$link)or die ('Error selecting to MySQL server.');
		mysql_set_charset('utf-8', $link) or die ('Error changing charset');		
		//add to the database
		$query = "INSERT INTO tblcomment (commentId, title, content, dateCreated) ".
		"VALUES (NULL, '$title', '$content', CURRENT_TIMESTAMP);";?>

Recommended Answers

All 9 Replies

mysql_selectdb(DB_NAME,$link)or die ('Error selecting to MySQL server.');

mysql_connect, no?

it's 1 line above it..
everything is working great until I add the javascript to the textarea

Arh sorry about that :-) It sure is there!

I have used tinymce, which work fine for me, and had no issues installing it.

I can recommend that for you!

I dont know if this helps you:

$SQL_INSERT = mysqli_query($connection, 
"INSERT INTO tblcomment
(commentId, title, content, dateCreated) 
(NULL, '$title, '$content', 'CURRENT_TIMESTAMP')") 
or die (mysqli_error($connection));	

You have some "" scattered around, maybe that could be an issue?

maybe that's cuz of all the editing, I didn't want to put here my entire code..basicly I made a form with a textarea, and it works. I type some text in, click save and it's saved in the DB, so that can't be the problem..
once I start adding the JS the $_POST is not getting anything, it's just empty.
BUT if I do this-
<textarea cols="50" id="area4" name="area4">TEXT</textarea>
then it saves me "TEXT", even if I delete it and type something else in the textarea.
I want a simple editor, like I said, no need for 40 icons. bold and underline would be enough, I'm so frustrated with this I think I'll just leave the textarea as it is.

if someone can post here a code that has a form with a simple editor (like on this forum) and a PHP code that saves the text into a DB I'd appreciate it.
thank you

you can decide which functionality you want, as shown below:

Sorry about the layout, I just copied it from my own site.

But as you can see on theme advanced buttons 2: you could simply just add BOLD, ITALIC, UNDERLINE - if that is what you are after.

So it would be:

<script type="text/javascript" src="wysiwyg/tinymce/jscripts/tiny_mce/tiny_mce.js"></script>

<script type="text/javascript">
        mode : "exact",
		elements : "indhold",
		theme : "advanced",				
theme_advanced_buttons: "bold,italic,underline,

		theme_advanced_toolbar_location: "top",
		theme_advanced_toolbar_align: "left",
		theme_advanced_statusbar_location: "bottom",
		theme_advanced_resizing: true,
		content_css: "../styles/admin.css",

But check the code, when installing :-)
Hope this helps you!

wow just tried tinymce and it....WORKED! lol con't believe let's hope it'd let me change it a little..

Good :)

Just read on the instructions on their website, its pretty extensive and will learn you how to get the functions your after.


yeah :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.