Jump to content

Integrating wysiwyg outputting numbers instead of content! newbie in need of hel


EvoDan

Recommended Posts

Wassup peeps! this looks like a great board to be a part of and i am hoping to learn a thing or two about php from here, but i have a feeling it is going to be a looong journey ;D.

I have been trying to set up a simple Content management system for a client using tinymce as the main editor form, but as i'm a total newbie and have just started learning php its proving quite difficult for me. What i have managed to do so far seems to be ok except the output on my public page echoed from my database isnt working right at all. So i was hoping somone here can take a look at my scripts and tell me whats right and wrong or point me in the direction of a tutorial that might help me.
so here is what i have so far....

I created a database with phpmyadmin called "boarhunt" and a table named "news" with two fields these are set like so..

1. id, int, (11), not null, primary key.
2.content, text, not null, default.

So it looks like this...
[img]http://img521.imageshack.us/img521/2966/dbshotdi1.jpg[/img]

For my form page i have tinymce setup with the form action set to post to postnews.php like so...
[code]<form action="postnews.php" method="post">
        <div id="elm1" style="width:450px; height:250px">
     
     
  </div>
<input type="submit" value="Submit">
    </form> [/code]

There is also some javascript in the head of the page to create the wysiwyg editor in the page where the id elm1 appears.

Here is my code for the postnews.php file...

[code=php:0]<?
$username="******";
$password="******";
$database="boarhunt";
$host="localhost";

if(isset($_POST['save']))

$content=$_POST['content'];


mysql_connect($host,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

{
$query = "insert into News (id,content) values ('','$content')";
mysql_query($query) or die(mysql_error('Error Query Failed'));

echo htmlspecialchars($query);
}


mysql_close();
?> [/code]

This seem all well and good as it seems to be posting to the database ok as everytime i submit something it adds rows to the database
and it increases in size so i assume that part is working, but if there is anything odd about it please let me know?


Next (and this is where i have hit a brick wall) i have tried to write an output script to go on my public pages to display the edited content
but all i get back is a bunch of numbers.

here is the script for my public page...

[code=php:0]<?
$host="localhost"; 
$username="******";
$password="******";
$database="boarhunt";



$db = mysql_connect($host,$username,$password);
@mysql_select_db($database) or die("Unable to select database");


$result = mysql_query("SELECT * FROM news");
while($row = mysql_fetch_array($result))
{
echo $row['id'] . " " . $row['content'];
}
@mysql_close($db);
?> [/code]

This is what this code is echoing back from my database

[img]http://img399.imageshack.us/img399/8571/echooutputgo0.jpg[/img]

So what i would like to know is how do i get the page to display the content i entered into the wysiwyg editor instead of those numbers?
And where am i going wrong with my script?
Are there any tutorials for coding a wysiwyg editor to work with a mysql database that i can follow?

Many thanks in advance to anybody who can help me out with this as i have been scratching my head over this for a week now and i have gotten as far as i can on my own with this. 
Link to comment
Share on other sites

Well i was hoping that the text i have put into the editor was going to be stored in the content field, how do i check? I'm not sure i follow what you mean by copy and pasting the html generated by this?
Do you mean from the page source in my browser, or from the database itself?
Link to comment
Share on other sites

[quote author=emehrkay link=topic=107181.msg429657#msg429657 date=1157592411]
doesnt tiny mce requre a textarea in the form? maybe that is your problem, i dont see one
[/quote]

You mentioning that has made me think of something and i was wondering if this would work?

If i build a cms from a tutorial like this...
http://www.devshed.com/c/a/PHP/Building-a-Relational-Content-Management-System-in-PHP-MySQL/

And then put tinymce (replace text area method) in to replace the normal text area in the tutorial would tinymce work with all its functionality along with the rest of the code?

Or would it require some extra php coding to get it going?
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.