Page 1 of 1

Displaying Formatted Content

Posted: Thu Nov 01, 2007 10:08 pm
by kkonline
I am working on a article management system (to store data in database and retrieve and show it)

I use a form structure to submit the data into database.
It has a field called "content" which has textarea type of input.
When i enter few paragraphs

for example the content entered is

Code: Select all

---content entered----
Basically you will want to run a PHP script file in specific intervals. Suppose you want to execute a php file called maintanence.php every one hour. This is what you do :-

The CRON Command is in the Following Format

CODE

[ Minute - Hour - Day - Month - Weekday ] - Command

The COMMAND, can be broken down in
---content entered----
It it stored as it is in the db. Next when i display the content I donot get the formated content. It shows just a continuous data without and formatting.

Code: Select all

-----displayed data-----
Basically you will want to run a PHP script file in specific intervals. Suppose you want to execute a php file called maintanence.php every one hour. This is what you do :-The CRON Command is in the Following FormatCODE[ Minute - Hour - Day - Month - Weekday ] - CommandThe COMMAND, can be broken down in
-----displayed data-----
I understand that i have to replace the line gap by <p> or <br> when displaying it. But how to perform it. The complete content is accessed using row['content']

Posted: Thu Nov 01, 2007 10:11 pm
by Kieran Huggins
nl2br() ?

Whoa... deja-vu!

Posted: Thu Nov 01, 2007 10:38 pm
by kkonline

Code: Select all

$content = nl2br($content);
               $content = str_replace("%", "", $_POST['content']);
               $content = str_replace("_", "", $content);
               $content = trim(mysql_real_escape_string($content));
It is not solving the purpose. No br tags are added to the database after doing the above processing. What could be the problem

Posted: Thu Nov 01, 2007 10:41 pm
by Kieran Huggins
re-check your code: you're overwriting the nl2br'd content from the POST array

Posted: Thu Nov 01, 2007 10:48 pm
by kkonline
Kieran Huggins wrote:re-check your code: you're overwriting the nl2br'd content from the POST array
yes you are correct.

corrected code is

Code: Select all

$content = nl2br($_POST['content']);
$content = str_replace("%", "", $content);
$content = str_replace("_", "", $content);
$content = trim(mysql_real_escape_string($content));
Thanks