what data type should I use for mySQL for Text Blocks like this area I'm typing in right now...???
on which, the format of the text will be preserve like carriage returns...
is varchar just alright?
block of text
Moderator: General Moderators
For your first question the answer is: No, varchar will be fine for strings no longer than 255 chars!
I guess you want to be able to store strings longer than 255 chars... for that, use TEXT (up to 65535 chars).
If you need more than 65535 chars check out this: http://htmlite.com/mysql003.php
And for your second question... I really can't understand your question, can you please try to explain it better? (or perhaps I'm the only one who can't understand it?
)
I guess you want to be able to store strings longer than 255 chars... for that, use TEXT (up to 65535 chars).
If you need more than 65535 chars check out this: http://htmlite.com/mysql003.php
And for your second question... I really can't understand your question, can you please try to explain it better? (or perhaps I'm the only one who can't understand it?
Oh... now I get you. feyd is right.
Let's say you read some data from the db and put in: $data
Use this code:
Make sure to call the functions in this specific order, it is extremely important or otherwise the date won't be shown correctly!
Let's say you read some data from the db and put in: $data
Use this code:
Code: Select all
<?php
$data = htmlspecialchars($data, ENT_QUOTES);
$data = str_replace(' ', ' ', $data);
$data = nl2br($data);
echo $data;
?>