PDA

View Full Version : Help with HTML TEXTAREA, PHP and MySQL, not sure where the problem is?


Manish
06-13-2007, 02:54 PM
Hi, I am just learning new programming languages and creating a website, not for a company just for my learning but i am stuck in a silly thing. I am using PHP and MySQL. And in HTML i am using TEXTAREA to write huge text. Basically if I write something like this:

This is first line,

This is second line.

When I store the above in MySQL database using TEXT datatype, and try to read it, it comes like this:

This is first line.This is second line.

They don't seem to come in separate lines.

Can you please tell me where the problem is.

Thankyou.

Oh, by the way this is the website i have created, still under construction:

http://www.sentosajaipur.com

But how can a user on my website will put <BR>, in yahoo answer if i press enter, it comes in a new line, so don't know how to do that.


as per what FlpcNerds.com is saying, i know <BR> is for breaking the line, but i know this and people who don't know computers, how can they put <BR> code when writing something in different lines.

FlpcNerds.com
06-14-2007, 05:32 AM
You need the BREAKLINE tag..which is <BR>

I do not know exactly if MySQL accepts HTML tags perfectly..

But <BR> is the HTML code for Breakline

example

This is first line,<BR>

This is second line.

will appear on a regular page as

This is first line,

This is second line.

Keep.It.Simple
06-14-2007, 08:05 AM
Looks like you need a line break - not just pressing enter in your code.

San-diel
06-14-2007, 11:05 AM
Try to use preformatted tags .

They are working when you want to put many

spaces between words, maybe also good for

new lines too.

chattterus
06-14-2007, 04:47 PM
Here is a better idea. I think the TEXTAREA return text with newline characters.

You are using php so replace newline characters with <BR> before you store the text in the database. I believe the strtr() function will work.

Another thing you could do is use a specialized text area box meant for editing. There are text boxes out there that will automatically insert Html into the text that you could put in your webpage. I believe you could find one on hotscripts.com

Yoda
06-14-2007, 08:28 PM
in PHP there is a function n12br($var);

this function transforms every Enter press of the client in br tag...this is the solution to your problem....I'm web designer...if you want to chat with somebody about Web Design my messenger id is: lauriry_1991;

Stock the contain of the textarea in a variable then use the function on it before stocking the text into a database.

Good Luck!

!!! Radwan !!!
06-14-2007, 10:36 PM
I suggest you to use dreamwaver, it will help you a little,

birdiemum
06-16-2007, 08:01 PM
A SQL database field ignores the formatting of your web page field. As far as your database knows, it's just a string field. If you want the lines to be separate, you'll have to have separate fields in the database.