0

HELP! I lost count of how many editors I tried! I don't understand why non of them work.
I'm trying this editor http://nicedit.com/index.php
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

<body>
<?php if (isset($_GET['...'])&&isset($_GET['..'])) {?>
<table>
   <tr>
     <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
	<td>
<?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');
});
</script>
	     <textarea cols="50" id="area4" name="area4"></textarea> 
	  <hr>
	  <input type="submit" name="submit" value="save" />
	 </td>
       </form>
    </tr>
</table>

}
 if (isset($_POST['submit'])) {
	if (isset($_POST['title']) && isset($_POST['area4')) {			
		$title = $_POST['title'];
		$content = $_POST['area4'];
		
		require_once('connectvars.php');
		$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);";?>
}
</body>
2
Contributors
9
Replies
10
Views
6 Years
Discussion Span
Last Post by 54uydf
1
mysql_selectdb(DB_NAME,$link)or die ('Error selecting to MySQL server.');

mysql_connect, no?

Edited by klemme: n/a

0

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

1

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) 
VALUES
(NULL, '$title, '$content', 'CURRENT_TIMESTAMP')") 
or die (mysqli_error($connection));	
}

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

Edited by klemme: n/a

0

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.

Edited by 54uydf: n/a

0

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

1

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">
tinyMCE.init({
        mode : "exact",
		elements : "indhold",
		theme : "advanced",				
		
plugins:"advlink,advlist,insertdatetime,autoresize,autosave,contextmenu,fullscreen,iespell,inlinepopups,media,paste,preview,safari,searchreplace,visualchars,wordcount,xhtmlxtras",
		
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",
	
});
</script>

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

Edited by klemme: n/a

0

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

Edited by 54uydf: n/a

1

Good :)

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

Solved?

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.