Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    Regular Coder
    Join Date
    Jun 2009
    Posts
    351
    Thanks
    75
    Thanked 0 Times in 0 Posts

    Simple question for most. Please have a look

    Ok basically i have a while loop but doesnt seem to work..

    Every time it goes around the loop i want it to append "<b>date:</b>$d<br/><b>title:</b>$title<br><b>email:</b>$email<br/><b>id:</b>$id<p><hr />" to the $body and then mail it at the end but this doesnt work. Can anyone tell me what is wrong please?

    PHP Code:
    $headers "MIME-Version: 1.0\nContent-type: text/html; charset=iso-8859-1\nFrom: AdsInDublin <info@adsindublin.com>";
    $body "";
        
    while (
    $i $num
        {
            
            
    $body. = "<b>date:</b>$d<br/><b>title:</b>$title<br><b>email:</b>$email<br/><b>id:</b>$id<p><hr />";
            
        
            
    $i++;
        }

        
    $to "something";
        
    $subject "somthing";
        
    mail($to$subject$body$headers); 

  • #2
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts
    first you should set $i = 0; to start.

    also where is $num coming from?

  • #3
    Regular Coder
    Join Date
    Jun 2009
    Posts
    351
    Thanks
    75
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by angst View Post
    first you should set $i = 0; to start.

    also where is $num coming from?
    That doesnt matter the loop is working in the script.. Its the mailing part that doesnt work.. of the script doesnt working because of the $body .= line when i comment out this the script works perfect

  • #4
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts
    simple,

    fix this:
    PHP Code:
    $body. = 
    to be

    PHP Code:
    $body .= 

  • #5
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Does php let us use . = for a concatenated assignment? I don't believe it does, that should probably be $body .= '...'; instead of $body. = '...'. I mean, it should still 'work', but it won't allow you to concat on the original variable.
    I need to test this when I get home, now I'm curious :P

    Edit:
    Oh, beaten to it :P
    Oh well hah.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #6
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts
    no it doesn't work, "Parse error: syntax error, unexpected '=" already tested.

  • #7
    Regular Coder
    Join Date
    Jun 2009
    Posts
    351
    Thanks
    75
    Thanked 0 Times in 0 Posts
    ok ha ha sorry didnt spot that...

    one last question for you

    PHP Code:
    $upperDate time() - (60*60*24*3);   // 3 days 
        
    $lowerDate time() - (60*60*24*4); ''// 4 days 
    can you give me a number which will be in between these two variables would 1266672836
    be one number?

  • #8
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Quote Originally Posted by angst View Post
    no it doesn't work, "Parse error: syntax error, unexpected '=" already tested.
    Sweet, saves me the test

    Quote Originally Posted by kevinkhan View Post
    ok ha ha sorry didnt spot that...

    one last question for you

    PHP Code:
    $upperDate time() - (60*60*24*3);   // 3 days 
        
    $lowerDate time() - (60*60*24*4); ''// 4 days 
    can you give me a number which will be in between these two variables would 1266672836
    be one number?
    What is it you're trying to do here? Are you trying to check a bound range between these two values?
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #9
    Senior Coder
    Join Date
    Jul 2009
    Location
    South Yorkshire, England
    Posts
    2,318
    Thanks
    6
    Thanked 304 Times in 303 Posts
    Quote Originally Posted by kevinkhan View Post
    PHP Code:
    $upperDate time() - (60*60*24*3);   // 3 days 
        
    $lowerDate time() - (60*60*24*4); ''// 4 days 
    can you give me a number which will be in between these two variables would 1266672836
    be one number?
    One is supposed to answer that how? You're generating a constantly evolving figure and then asking for a static part way value? Or, are you actually asking how to generate a value for three and one half days?


  •  

    Posting Permissions

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