Link to home
Start Free TrialLog in
Avatar of rpkhare
rpkhareFlag for India

asked on

Store Rich Text in MySQL Table and display with HTML

I have given an Entry Form to the user to input values that are stored in a MySQL table. There is one column called "Project Details", wherein the user can input upto 200 characters and this column is of type "varchar".

Till here everything is fine. The problem starts when the project details contain a number of points that are to be listed on the HTML page as:

(1) .........
(2) .........
(3) .........

It is unsure whether the project details is of one line, one paragraph, a simple text or a numbered list.

Is there any way to save the project details in rich text format in the MySQL table and when PHP shows the page of my website, the text gets listed as it was pasted?
ASKER CERTIFIED SOLUTION
Avatar of LordZardeck
LordZardeck
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Good point on changing the column type. VARCHAR won't hold much, then you add even more to store when you add html code to that.
Avatar of rpkhare

ASKER

@Hube02:

I am attempting that JavaScript class. It works fine. But the problem is that when I pass the converted RTF to HTML code in MySQL Insert query, the query crashes. The tags enclosed in POST variables are creating problem.
what's your query? please include the html that you tried to insert.
A possible problem will be the quotes and other special characters in the HTML. Before doing the insert use mysql_real_escape_string() on the input value, actually, you should use this function on every value that is input by a user to avoid any problems or possible attempts at hacking your database.
That's one reason I asked for the input. i thought that might be it, but I wanted to check to be sure. Single and double quotes give the biggest hassles for php programmers, espically when dealing with databases.
Avatar of rpkhare

ASKER

Thanks