1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

PHP Script help....line breaks??

Discussion in 'Software Development' started by scoates, Sep 12, 2003.

Thread Status:
Not open for further replies.
Advertisement
  1. scoates

    scoates Thread Starter

    Joined:
    Sep 5, 2003
    Messages:
    11
    Hi.

    I've got a php script I'm using to email form results from a webpage to the client. However, I can't seem to get the line breaks in the output to sit right...they're all over the place!

    Here an excerpt of my script:

    Code:
    $messageproper =
    
    	"This message was sent from:\n" .
    	"$http_referrer\n" .
    	"COMMENTS:\n\n" .
    	$comments .
            "NAME:\n\n" .
            $name .
            "ADDRESS:\n\n" .
            $street .
            "APT:\n\n" .
            $aptorsuite .
            "CITY:\n\n" .
            $city .
            "PHONE:\n\n" .
            $phone .
    	"\n\n---------------------- END ----------------------------\n" ;
    
    Unfortunaltely, the results appear like this in the out put (email):

    This message was sent from:
    http://www.websiteurl.com/general/contest.html
    COMMENTS:

    NAME:

    George McFlyADDRESS:

    166 Main StreetAPT:

    1225CITY:

    TorontoPHONE:

    416-777-7777

    ---------------------- END ----------------------------

    Why arent the line braking correctly? Isn't "\n" supposed to do that? Why are the first few lines and the last line breaking alright. The problem seems to start at the "Name" result.
     
  2. Rockn

    Rockn

    Joined:
    Jul 29, 2001
    Messages:
    21,334
    Put in the vb equivilent of the line break.

    &VbCrLf
     
  3. Gibble

    Gibble

    Joined:
    Oct 9, 2001
    Messages:
    27,087
    Rockn, he's not using VB :)

    it's doing exactly what you told it to do, but you need to put a \n after you interpolate a variable.

    ie.
    You have this....
    PHP:
    "COMMENTS:\n\n" .
    $comments .
    "NAME:\n\n" .
    It should be more like:
    PHP:
    "COMMENTS:\n\n" .
    $comments .
    "\n\n" 
    "NAME:\n\n" .
    Notice the extra \n\n between $comments and "NAME:" :)

    --HTH
     
  4. Rockn

    Rockn

    Joined:
    Jul 29, 2001
    Messages:
    21,334
    Oh well....I am still green as hell with PHP.
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/164262

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice