son.of.the.morning Posted December 11, 2011 Share Posted December 11, 2011 Am adding text with paragraphs into my database but when i view that data on another page it's just one big block of text. :S Anyone no how i can stop this? Quote Link to comment Share on other sites More sharing options...
SergeiSS Posted December 11, 2011 Share Posted December 11, 2011 First of all show you code Otherwise it's difficult to say something. Quote Link to comment Share on other sites More sharing options...
Winstons Posted December 11, 2011 Share Posted December 11, 2011 son.of.the.morning Show your code. Â SergeiSS Hello from phpforum.ru by Winston Quote Link to comment Share on other sites More sharing options...
son.of.the.morning Posted December 11, 2011 Author Share Posted December 11, 2011 invoking the class $values = array("$title","$img","$post","$aurthor_id","$category_id","$date_posted"); $fields = array('title,','img,','post,','aurthor_id,','category_id,','date_posted'); $obj= new DatabaseInsert; $obj->DatabaseConnectionRequire(); $obj->ArticleInsert($values,$fields,$table);  The Insert Class class DatabaseInsert { function DatabaseConnectionRequire() { include("../scrips/php/database.connection.class.php"); include("../scrips/php/database.settings.php"); include("../scrips/php/database.connection.class.invoke.php"); } function ArticleInsert($values,$fields,$table) { $values_imploded = implode(" ",$values); $fields_imploded = implode(" ",$fields); $i = "INSERT INTO $table ($fields_imploded) VALUES ($values_imploded)"; //mysql_query($i) or die (mysql_error()); //Uncomment ^ this to check the query for errors. if (!(mysql_query($i))) {   echo "Sorry, something whent wrong there..."; } else { echo "<strong><p style='color:green;'>Content added sucessfully!!!</p></strong>"; } } }  The View point if(isset($_GET['id'])) { // Get the id and select it's corresponding record $id = $_GET['id']; $query = "SELECT * FROM blog_posts INNER JOIN post_categories ON blog_posts.category_id=post_categories.id WHERE blog_posts.id = $id"; $get_results = mysql_query($query) or die (mysql_error()); $results = mysql_fetch_array($get_results); } <?php echo $results['post']; ?> // the main body of the article  Quote Link to comment Share on other sites More sharing options...
SergeiSS Posted December 11, 2011 Share Posted December 11, 2011 Instead of this code echo $results['post']; // the main body of the article Try this echo '<pre>'.$results['post'].'</pre>'; // the main body of the article Quote Link to comment Share on other sites More sharing options...
son.of.the.morning Posted December 11, 2011 Author Share Posted December 11, 2011 It's coming one big line for each paragraph with that :S Quote Link to comment Share on other sites More sharing options...
SergeiSS Posted December 11, 2011 Share Posted December 11, 2011 Well... Let's start again. Â "Am adding text with paragraphs into my database" - what is the source of you code? Somebody add info at your page? If "yes" - what do you use for it: textarea or any other object? You didn't show it in your code. Quote Link to comment Share on other sites More sharing options...
son.of.the.morning Posted December 11, 2011 Author Share Posted December 11, 2011 I use a text area. When i check the post inside my database it shows paragraphs but when i try echo that record column out it doesn't show the paragraphs it just shows one big chunk of text.       <div id="ArticleBody" style="font-size:13px; font-size: 13px; margin-top: 26px; width: 729px;">              <?php echo bbcode($results['post']); ?>        </div> Quote Link to comment Share on other sites More sharing options...
Winstons Posted December 11, 2011 Share Posted December 11, 2011 Try it <?php echo nl2br(bbcode($results['post'])); ?> Quote Link to comment Share on other sites More sharing options...
son.of.the.morning Posted December 11, 2011 Author Share Posted December 11, 2011 I have a solution using the nl2br() function. Quote Link to comment Share on other sites More sharing options...
son.of.the.morning Posted December 11, 2011 Author Share Posted December 11, 2011 haha thanks for you help man Quote Link to comment Share on other sites More sharing options...
SergeiSS Posted December 11, 2011 Share Posted December 11, 2011 Winstons's solution is correct, of course. But in order to you know - you don't have to use this function nl2br() in 2 cases: //if you show this text again in textarea, maybe in any form, for editing echo '<textares>'.$results['post'].'</textarea>'; // or as I said earlier - you just send it to browser with PRE tags and browser show it correctly echo '<pre>'.$results['post'].'</pre>'; Quote Link to comment Share on other sites More sharing options...
son.of.the.morning Posted December 11, 2011 Author Share Posted December 11, 2011 nice one guys! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.