SitePoint Sponsor

User Tag List

Results 1 to 25 of 25
  1. #1
    SitePoint Zealot
    Join Date
    Jan 2006
    Posts
    190
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Quotes within quotes

    My heads starting to burn up with rage. Everything i tried doest seem to work

    Code:
    $message = '<html><body><p>Welcome to url,<br /><br /> The account you created is waiting to be validated.<br />' .
    'Your Validation code is:" $usercode "<br />Click the link below, or copy and paste the code when asked for it.<br/>' .
    '<a href="url/validateaccount.php?code='$usercode'"/>Validate Account</a><br /><br />We hope you to see you soon!<br />The Admin team<br />' .
    '<br /><i>This is an automated mail. Replies to this address are disregarded. Please use the <a href="urle/contact.php">contact page</a> instead.</i></p></body></html>';
    Im creating an email to send, which contains a link to a url, and some info from the php script. But whichever way round i try and quote it all i get a mismatch error or it tries to parse things it shouldnt.

    im using ' to enclose the whole text, as i need " inside for the links, is this the right way of thinking about it?

  2. #2
    SitePoint Zealot mudda's Avatar
    Join Date
    Jul 2005
    Posts
    113
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You forgot to put in the periods between your text & your variables.

    PHP Code:

    "Your Validation code is:".$usercode."<br />"

  3. #3
    SitePoint Evangelist DMacedo's Avatar
    Join Date
    May 2004
    Location
    Braga, Portugal
    Posts
    596
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Cool

    Your problem is that you have to concatenate the place where you're placing the string.

    Try this:
    PHP Code:
    $message '<html><body><p>Welcome to url,<br /><br /> The account you created is waiting to be validated.<br />' .
    'Your Validation code is:'.$usercode.'<br />Click the link below, or copy and paste the code when asked for it.<br/>' .
    '<a href="url/validateaccount.php?code='.$usercode.'"/>Validate Account</a><br /><br />We hope you to see you soon!<br />The Admin team<br />' .
    '<br /><i>This is an automated mail. Replies to this address are disregarded. Please use the <a href="urle/contact.php">contact page</a> instead.</i></p></body></html>'
    ~ Daniel Macedo

  4. #4
    SitePoint Zealot
    Join Date
    Jan 2006
    Posts
    190
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ah thanks, i didnt know those were required.

    (you should see the bruises on my forehead from this..)

  5. #5
    SitePoint Enthusiast homesonsale's Avatar
    Join Date
    Jan 2004
    Location
    Burlington, Toronto - former UK
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by L4suicide
    Ah thanks, i didnt know those were required.

    (you should see the bruises on my forehead from this..)
    LOL
    Maybe wearing a cycle helmet whilst coding would be better for your health?

  6. #6
    SitePoint Evangelist DMacedo's Avatar
    Join Date
    May 2004
    Location
    Braga, Portugal
    Posts
    596
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here is the extra information you should read.
    ~ Daniel Macedo

  7. #7
    Wadge! F4nat1c's Avatar
    Join Date
    Oct 2005
    Location
    South Wales, UK
    Posts
    1,134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I only do it for large amounts of data.

    PHP Code:

    echo "$var1 is $var2"
    Would work fine, without the need for single quotes or full stops.
    OMFG SitePoint ROXORZ TEH BIG ONE111!
    Wish you were invisible?

  8. #8
    SitePoint Evangelist DMacedo's Avatar
    Join Date
    May 2004
    Location
    Braga, Portugal
    Posts
    596
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Cool

    For optimization reasons, you should use single quotes as often as possible
    ~ Daniel Macedo

  9. #9
    SitePoint Zealot
    Join Date
    Jan 2006
    Posts
    190
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ah ok

    PHP Code:
    mail('$email'"Account Registration"'$message',
        
    "To: New Player <'$email'>\n" .
        
    "From: MyGameAdmin <validationteam@myurl.com>\n" .
        
    "MIME-Version: 1.0\n" .
        
    "Content-type: text/html; charset=iso-8859-1"); 
    doesnt seem to actually send an email? is that because im stupid?

  10. #10
    SitePoint Evangelist DMacedo's Avatar
    Join Date
    May 2004
    Location
    Braga, Portugal
    Posts
    596
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Cool

    Come on man, we can't be teaching you every little piece of PHP or you'll never start learning.

    Quote Originally Posted by DMacedo
    Here is the extra information you should read.
    Read what's there and you'll understand what's wrong with that code, ok?
    ~ Daniel Macedo

  11. #11
    SitePoint Zealot
    Join Date
    Jan 2006
    Posts
    190
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    your link (was) broken

    Code:
    mail("myemail@myplace.com","My Subject","Random msg");
    and im trying to test with that too, which should work :/

  12. #12
    SitePoint Evangelist DMacedo's Avatar
    Join Date
    May 2004
    Location
    Braga, Portugal
    Posts
    596
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Cool

    Try this one

    If that code doesn't work, then the problem could be in your PHP configuration, is it a windows, localhost server?
    ~ Daniel Macedo

  13. #13
    SitePoint Zealot
    Join Date
    Jan 2006
    Posts
    190
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yeah it is windows, localhost..

  14. #14
    SitePoint Evangelist DMacedo's Avatar
    Join Date
    May 2004
    Location
    Braga, Portugal
    Posts
    596
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Edit c:\windows\php.ini, set the SMTP directive to your ISPs SMTP server (they should provide you with one) then restart your http server, and that should solve the issue.
    ~ Daniel Macedo

  15. #15
    SitePoint Evangelist DMacedo's Avatar
    Join Date
    May 2004
    Location
    Braga, Portugal
    Posts
    596
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Cool

    And don't forget to read the link above so you'll learn something out of this
    ~ Daniel Macedo

  16. #16
    SitePoint Zealot
    Join Date
    Jan 2006
    Posts
    190
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by DMacedo
    And fon't forget to read the link above so you'll learn something out of this
    Ive been reading all day and i kinda already knew alot of the string stuff, just trying to get my head round HEREDOC atm

    Erm, i dont think i can edit that file :| is there anyway i can check if those settings are already done? i dont know much about how the hosting works, i have an account at godaddy and theres nothing there to help me investigate

  17. #17
    Wadge! F4nat1c's Avatar
    Join Date
    Oct 2005
    Location
    South Wales, UK
    Posts
    1,134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
     mail('$email'"Account Registration"'$message',
        
    "To: New Player <'$email'>\n" .
        
    "From: MyGameAdmin <validationteam@myurl.com>\n" .
        
    "MIME-Version: 1.0\n" .
        
    "Content-type: text/html; charset=iso-8859-1"); 
    No, No, No!

    PHP Code:
     $subject "Account Registration";

     
    mail($email$subject$message,
        
    "To: New Player <$email>\n" .
        
    "From: MyGameAdmin <validationteam@myurl.com>\n" .
        
    "MIME-Version: 1.0\n" .
        
    "Content-type: text/html; charset=iso-8859-1"); 
    Don't quote variables. Learn the syntax.
    OMFG SitePoint ROXORZ TEH BIG ONE111!
    Wish you were invisible?

  18. #18
    SitePoint Zealot
    Join Date
    Jan 2006
    Posts
    190
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yeah i did work that one out
    But im still not getting any mails (i should have edited that i guess)

  19. #19
    Wadge! F4nat1c's Avatar
    Join Date
    Oct 2005
    Location
    South Wales, UK
    Posts
    1,134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So what's the total code you have thus far?
    OMFG SitePoint ROXORZ TEH BIG ONE111!
    Wish you were invisible?

  20. #20
    SitePoint Evangelist DMacedo's Avatar
    Join Date
    May 2004
    Location
    Braga, Portugal
    Posts
    596
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Actually here it was ok:

    PHP Code:
    "To: New Player <'$email'>\n" 
    And I wanted him to get there
    ~ Daniel Macedo

  21. #21
    SitePoint Zealot
    Join Date
    Jan 2006
    Posts
    190
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The bit that isnt working:
    PHP Code:
    mail("myemail@confidential.com","My Subject","Random msg"); 

  22. #22
    SitePoint Evangelist DMacedo's Avatar
    Join Date
    May 2004
    Location
    Braga, Portugal
    Posts
    596
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Trust me, the error is not on the PHP code as that's right.
    But you have to have an SMTP server configured in your php.ini, have you done that already?
    ~ Daniel Macedo

  23. #23
    SitePoint Zealot
    Join Date
    Jan 2006
    Posts
    190
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    As i said im not sure how to check, and id guess it would already be configured correctly for me (it was already configured for asp's mailing functions..)

  24. #24
    SitePoint Evangelist DMacedo's Avatar
    Join Date
    May 2004
    Location
    Braga, Portugal
    Posts
    596
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In windows you have to configure an SMTP server to send e-mail messages through PHP. Try asking your ISP what's their SMTP as usually they allow mail to be sent by their clients.
    ~ Daniel Macedo

  25. #25
    SitePoint Zealot
    Join Date
    Jan 2006
    Posts
    190
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    smtp smtp.secureserver.net

    is what it lists in my DNS manager..


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •