Problems With Data Formatting

free web hosting
Open Discussion > CONTRIBUTE > Computers > Programming Languages > PHP Programming

Problems With Data Formatting

masugidsk8r
I have a MySQL database which stores articles. A sample article would look like this:

CODE
This is a body. This is a body.This is a body.This is a body.This is a body.This is a body.This is a body.This is a body.This is a body.This is a body.This is a body.This is a body.This is a body.This is a body.This is a body.This is a body.This is a body.

This is a body.This is a body.This is a body.This is a body.This is a body.This is a body.This is a body.This is a body.This is a body.This is a body.This is a body.This is a body.This is a body.This is a body.


That's how it's displayed in the MySQL Database. Currently the data type is "TEXT". But when I load it on a php page to display that same article, it would show the same data but wouldn't have separate paragraphs. How would I be able to display the text in separate paragraphs?

Reply

jlhaslip
On the php.net site, search for htmlentities() and nl2br(), the functions which converts potentially dangerous and damaging code tags from their 'regular' form into a format which is not dangerous nor damaging and there are others I am sure . Finding these functions and following the links in those descripptions will lead you to other functions to use, too.
The original data contains internal characters for tabs, carriage returns, new lines, etc, so the data needs to be altered from its source, to some thing safe. Use functions like these to do the cleansing. Then, when you remove the data from the database and proceed to print it or display it, the product looks the same as when it went in.

http://www.php.net

Reply

masugidsk8r
Thx man, that really worked.

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.

Recent Queries:-
  1. mysql_fetch_array missing carriage returns - 726.27 hr back. (1)
Similar Topics

Keywords : problems, data, formatting

  1. Php + Mysql Question!
    While inserting data into MySQL, how can I know if the data I'm in (4)
  2. Php Email Validation
    A PHP data validation class with many functions (1)
    I've been reading through my old php book (PHP 4.1) and came across this data validation class.
    It can check a number of things ranging from telephone numbers , credit card number formats, email
    address and some others. I checked out some of the methods although I didnt expect it to work 100%
    because I've found source code errors thoughout the book and CD. I tested out a few of the
    methods to check and some of them did return expected results but some didnt either so the data
    validation class was not perfect and it didnt really bother me. The cool thing I found....
  3. Using Multiple Selection Array In Table To Order Data
    Using multiple selection array in table to order data (1)
    have a form that has a multiple select choice, like this: CODE <form method="post"
    action="display.php" <select multiple name="selectsort[]">
    <option value="code">Code</option> <option
    value="amount">Amount</option> <option value="dateammended">Date
    Ammended</option> <option value="expreviewdate">Expiration/Review
    Date</option> <option value="effectivedate">Effective Date</option>
    <option value="e....
  4. Php Problems
    Clan Web site Problem (3)
    Okay, so I have an old version of Nettek that I would like to modify. There is a bug that when you
    get to the rank required for Set Rank, you can set your rank or other people's ranks to what
    ever you want, even Webmaster and that's something I'd like to not have. I am wondering how
    to fix the problem. What would I modify in the coding to set have it so you can only move people up
    to 1 rank below you at best? I'm still learning PHP and can't modify things like this quite
    yet.....
  5. What Does This Do?
    $ban = ($data->login) ? $lban : $iban; (4)
    I'm correcting a 'few' php-files for a friend, but I got this line of code: CODE
    $ban = ($data->login) ? $lban : $iban; and I don't know
    what it does xD Could someone please explain me what this line does? Thanks....
  6. Putting Data Of 2 Pages In Mysql At Once
    (1)
    suppose i have a page, page.php?part=1 there i have some text fields. user will give input, but
    after taking input, it will not put the data in mysql .. but it will take to the next step..
    page.php?part=2 (if any field is left blank, it will not go to next page.. ) . and there also some
    fields.. after the user has filled that form also, then it will insert all data (from part1 and
    part 2) in mysql. i want to ask, how i can collect data from 2 pages and put in mysql at once.....
  7. Problems With Php
    (5)
    Recently, my system was infected by a Trojan Horse. Since then, I've been finding files missing
    and now my PHP will not work, my Apache server will not display PHP files, i've tried getting
    rid of the files in my C:\Windows and C:\Windows\system32 folders but nothing is
    working. (it comes up with 'file in use') All help greatly appreciated.....
  8. How Good Is This Data Cleaning Function?
    (2)
    Hi all, this is my first function and as part of a script and i just want to know a couple of
    things. here is the code for the function: CODE <? function
    clean($dirty_string) { $muddy_string = stripslashes($dirty_string);
    $murky_string = strip_tags($muddy_string); $clean_string =
    htmlentities($murky_string);      }; ?> So the first thing is how secure is
    it? the script this will be used in connects to a database and sends an email so it needs to stop
    SQL injections and any email ab....
  9. Preg_replace Problems
    (7)
    Sigh... preg_replace is getting very annoying for me. Could sombody tell me what I'm doing
    wrong? Im making a bbcode replace for the forums I made, and preg_replace is being a b****...
    Right now Im working on the tag, and I want to check for valid URL's, because idiots in the
    forum are adding js and stuff in the image tags and messing it all up. So i put a function in the
    array that holds all of the replacements: CODE
    $main_search=array('/\[b\](.*?)\[\/b\]
    /is','/\[i\ ....
  10. Mysql Authentication Problems
    (11)
    I installed the new version of both php and mysql on my computer and I am trying to work on a
    database. The problem is the following. Even though I have the latest version of both php and mysql,
    and I have created users in the new mysql version, I still get the problem that I get an error
    message about authentication problems. I have no clue what I am doing wrong. It did work for a short
    period of time, but somehow it is no longer working. Is there anyone who has a tutorial on how to
    install both php and mysql? I have the feeling that there are a lot of settings in my.in....
  11. String/text Formatting?
    (4)
    right i was wondering if someone could help me with this: I notice on this site if i make a topic
    for example WAppY rOCks WaP, it will come out like Wappy Rocks Wap. I also want to do this to my
    forums, can anyone give me the code to format a string of text in this way? THANKS IN ADVANCE ....
  12. Odbc Form Problems
    (0)
    Hy everyone! I am moderately familiar
    with PHP and have been using it for a couple years for various different things.
    Basic information about my system:
    PHP 5 MySQL 4.1 Apache Windows XP Pro I'm using
    PHP/MySQL for a web-based server and have an ODBC set up in my office. I'm running into some
    problems using the ODBC code as opposed to the MySQL code in some scripts I ha....
  13. Phpnuke Newsletter Sending Problems
    (0)
    i have a problem sending newsletters....when i send them no1 receives it...i tried sending to the
    registered users on my site which im in and i didnt recieve it in my mail...i dont know why this is
    happening...it says the newsletter is sent...but we get nothing in our mail... heres the code
    QUOTE /************************************************************************/ /* PHP-NUKE:
    Web Portal System */ /* ===========================
    */ /* ....
  14. Loading Mysql Data Into A Table
    (10)
    Hey i have a little problem with my php script. i dont really know how to make it work ^^; I want to
    have this exact table: ' I made mysql table that has one column for id(auto-increment,
    primary key), and then it has row and collumn and text. row means which row in the html table and
    collumn wich collum. (obviously /tongue.gif" style="vertical-align:middle" emoid=":P" border="0"
    alt="tongue.gif" />) here is the mysql table screenshoted from phpMyAdmin: r means row and c
    collumn /tongue.gif" style="vertical-align:middle" emoid=":P" border="0" alt="tongue....
  15. Major Problems With Php Script
    Hold on for this one! (8)
    Okay, so I got a php script for my site called php Bible. So I get it and go to install it, and
    then the problems start. You see it uses php, dud, to search and view scripture. So here are the
    instructions: QUOTE 1) Upload the files to a useful place inside your web server's
    document tree. 2) Change the things that look wrong in config.php. 3) Make sure "AcceptPathInfo
    ON" (or analogous) is somewhere in your PHP file section of your web server config. 4) Go over
    steps 2 and 3 again, because you probably missed something for lack of documentation. So....
  16. Same 1 Registeration Data For Different Purposes
    (4)
    I want to install 4 scripts on my website .. 1- Gallery 2-Classfied Ads 3-Game Cheats Script (A
    simple script where ppl can register and then submit the cheats) 4-Php Nuke The problem is that all
    of 4 scripts needs registeration of members (use 4 different databases).... I want that all the
    member which is registered at one place can login at all of the services..i mean , one registeration
    form , that can work for all.. how i can do it ? Please tell in details..thanks.....
  17. Include Funtion Php Problems
    in xammp and php 5.1.1 (11)
    Hi, I just recently installed the latest versin of XAMMP on my computer which comes with php5.1.1
    and i have been noticing some problems with the include(); funtion. This is a code that worked
    fine on trap17 hosting so I am thinking it has something to do with the php version of 5.1.1 since
    trap17 uses 4.3.X. Now what the actual problem is is using the variables in the include function.
    If i have a normal include sentence like this one: CODE include "hello.php"; then it
    works fine but as soon as i start using variables it somehow dosent work at all. ....
  18. Problems With Php Form?
    Can you please help? (7)
    I am trying to install a PHP form. I am using a tutorial I found in the tutorials section. It was
    really good, but I have a few problems. Here is the link, if you need it:
    http://www.trap17.com/forums/index.php?sho...ic=8118&hl=form Anyway, so I place the mailform.php
    in an html document on file manager right? So I do that. And I put it in the body: CODE
    <?php $Name = $_POST['Name']; $Subject =
    $_POST['Subject']; $Email = $_POST['Email'];
    $Site = $_POST['Sit....
  19. Finding Data In Meta Tags
    using php to search Meta Tags for data (0)
    In the Head portion of an Html file, there are usually several Meta Tags that contain data about
    various things, like the tag for keywords, an Author's name or maybe a description field. Here
    are two example Meta tags: HTML meta name =" Keywords " content=" keyword1, keyword2 " />
    meta name =" Description " content=" A Description of the file's content is here " /> So,
    what I have a question about concerns checking a file to see what information is included in these
    tags and using that information as variables or content in the output of the page....
  20. Listing From Table Row Data
    Listing all members (5)
    Hello, it's been a while since i've been active in the PHP Board ( i used to be really
    active in here ), not only to help others but also to request help ( people knowing those requests,
    dont share your bad experience with my requests /tongue.gif' border='0'
    style='vertical-align:middle' alt='tongue.gif' /> ) Anyway, i am requesting help on a listing of
    members, i totally forgot about how to fetch the rows from a table and display each row, i thought
    it was: CODE $result=mysql_query("SELECT * FROM $usertable ORDER BY id
    DESC") or....
  21. Help With Reading Files
    Read and replace/insert data from form (5)
    Hi, Does anyone know how i can do this, or scripts that will work on Trap17's servers and will
    do the following: I have a .doc file form. Which i want to have filled in automactically, by HTML
    Form and emailed to my address, with the data filled in. Any ideas? I have heard many differing
    things, like XML, RTF, DOC, PDF... I have serched through many places and come up empty handed with
    anything that works. /sad.gif' border='0' style='vertical-align:middle' alt='sad.gif' /> ....
  22. <? Include ?> Problems
    (4)
    Well, I'm new to PHP, and I get tons of problems when I use the include tags: Let's say my
    site is www.mysite.com, and the menu is www.mysite.com/menu.htm. The site I want to include menu.htm
    in is not in the same folder as menu.htm, but in "folder2": www.mysite.com/folder2/index.php The
    images in menu.htm are located in it's own folder: www.mysite.com/images. However, when I load
    index.php with , the images won't load. Then I try to check the image location and it says that
    the images that didn't load was located in www.mysite.com/folder2/images ....
  23. Form To Pdf, With Email?
    Wanting to Submitt Data to PDF (3)
    Hi all, This sounds like a good place to ask this, I have a form Click Here to View that when
    submitted will put the values into the PDF Here Is there a way in which to have the filled in
    form both viewed to the user? and also have it emailed to me as an attachment. Any code or help
    would be good... I get basics, but this stuff is hard to get to work and i can't get it to.....
  24. Browser Problems, Maybe?
    Firefox vs IE (6)
    Alright, I coded something the other day for the game I am working on making, and a few of my
    friends I allowed to get on it and test things out. Well....the ones that were on IE their
    characters were made but the User variable as in which account they were on just stayed blank, while
    with my friends that were on Firefox, everything worked fine and they could play perfectly... So I
    was wondering, with PHP sql codes being sent to the database, is there something special you have to
    do to make it work on both, or could it be a setting on the IE that was messing with it......
  25. Postnuke Install Problems On Subdomains
    (1)
    I'm trying to install PostNuke on a empty server I allready got PostNuke downloaded and uploaded
    the downloaded files to the server but I can't get it to work. I'm trying to do this on 2
    servers both are sub-domains and both support php. One of them has a MySQL database and MyAdmin but
    I can't find them anywhere on the sub-domain. I'm pretty new to this and any advise would be
    more then welcome to me. I tryed looking for a MySQL database to install but when I do I get
    something like 30 different versions and don't know whitch one I need I tryed th....
  26. Php And Gd Tutorial
    I'm having problems (6)
    I am trying to learn PHP and was wondering what is wrong with the tutorals on this site:
    http://www.phpfreaks.com/tutorials/105/1.php I copied the code between the body tages in my site,
    and am returned with an error regarding headers. Does anybody why this is?....
  27. Help Importing Mysql Database Results
    Need help formatting link (3)
    I am having trouble formatting my table to display the results of a mySQL query the way I want.
    Here is the part of my code: CODE $result = mysql_query("SELECT * FROM uploads
    WHERE Category='Drama'") or die(mysql_error()); ?> <table
    cellspacing="2" cellpadding="2"> <tr> <th>Title</th>
    <th>Author</th> <th>File</th></tr> <?php // keeps
    getting the next row until there are no more to get while($row = mysql_fetch_array....
  28. How To Redirct Post Data ?
    (4)
    I have a form, from where the data is being posted to a php script. Now in the php script the script
    has to forward the data to another script with posted data. I know this can be done using header but
    i don't know how to keep the data posted with form in POST method. For example: The form
    below: Code: Now its posting data using POST method to 1.php...and now 1.php will
    redirect everything to another php script with the data and it should be in POST method ... How can
    i do this ? Thanks. ....
  29. Problems With Apostrophes [ ' ] In Php
    (4)
    Yes I have another problem. I have a blog that I made with php and mysql. It's working just
    fine except for the text being displayed on the page. Everytime there's an apostrophe
    encountered, *something puts a slash before it. It's fine in the database only the page.
    Probably a problem with PHP. I hope you understand what I say. Here's a sample line displayed
    in my blog: -- It\'s Saturday but I\'m still in the office. -- ....
  30. Ftp Script Problems - Authentication Failure
    (3)
    I uploaded the code as a text file because it's pretty big: http://beeseven.trap17.com/ftp.txt
    As I said it can't login. I get this error: Warning : ftp_login(): Authentication failed,
    sorry in /home/beeseven/public_html/ftp.php on line 45 I think it might have something to do
    with character encoding, but I'm not sure. If you think it is, what kind of encoding would work
    as if I typed it directly? I tried putting it in the file, but then I got the missing required
    fields error.....

    1. Looking for problems, data, formatting

*RANDOM STUFF*





*SIMILAR VIDEOS*
Searching Video's for problems, data, formatting

*MORE FROM TRAP17.COM*
advertisement



Problems With Data Formatting



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute your information that might help someone here.
Ask your Doubts & Queries to get answers.. "Together, We enlight each other!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE