didster Posted April 9, 2008 Share Posted April 9, 2008 Can anyone please tell me what I am doing wrong? The syntax is wrong somewhere as the screen goes blank when processed. $message .= "\n\n-- Chk --\n\n" . $_POST['chkno'][0] . $_POST['chkno'][1] . $_POST['chkno'][2] ; if (!empty($contactname)) { $message .= "\n\n-- Contact Name --\n\n" . $contactname; }; Link to comment https://forums.phpfreaks.com/topic/100295-solved-syntax-problem/ Share on other sites More sharing options...
Kieran Menor Posted April 9, 2008 Share Posted April 9, 2008 There should be no semicolon after a closing bracket (last line). Link to comment https://forums.phpfreaks.com/topic/100295-solved-syntax-problem/#findComment-512841 Share on other sites More sharing options...
didster Posted April 9, 2008 Author Share Posted April 9, 2008 Still doesnt work am afraid Link to comment https://forums.phpfreaks.com/topic/100295-solved-syntax-problem/#findComment-512845 Share on other sites More sharing options...
AndyB Posted April 9, 2008 Share Posted April 9, 2008 What you posted as code has no output to the screen. Link to comment https://forums.phpfreaks.com/topic/100295-solved-syntax-problem/#findComment-512849 Share on other sites More sharing options...
didster Posted April 9, 2008 Author Share Posted April 9, 2008 No I know, the following works fine on its own, it is part of an email that automatically sends $message .= "\n\n-- Chk --\n\n" . $_POST['chkno'][0] . $_POST['chkno'][1] . $_POST['chkno'][2]; It is when I try adding this statement. Can I have a statement on the fly like this? Cheers... if (!empty($contactname)) { $message .= "\n\n-- Contact Name --\n\n" . $contactname; }; Link to comment https://forums.phpfreaks.com/topic/100295-solved-syntax-problem/#findComment-512854 Share on other sites More sharing options...
AndyB Posted April 9, 2008 Share Posted April 9, 2008 $message .= "\n\n-- Chk --\n\n" . $_POST['chkno'][0] . $_POST['chkno'][1] . $_POST['chkno'][2] ; if (!empty($contactname)) { $message .= "\n\n-- Contact Name --\n\n" . $contactname; } Note the removal of the semicolon after the curly brace. That code works. It obviously doesn't produce any output, but it works. It may not be doing what you expect, but it does work. Link to comment https://forums.phpfreaks.com/topic/100295-solved-syntax-problem/#findComment-512857 Share on other sites More sharing options...
didster Posted April 9, 2008 Author Share Posted April 9, 2008 I know that there is something wrong as without the if statement, the page processes correctly and returns the 'thankyouurl' page. When I put the if statement in, the php page tries to load up and therefore is just a blank page. Very confused! @mail($to, $subject, $message, $headers); header( "Location: $thankyouurl" ); Link to comment https://forums.phpfreaks.com/topic/100295-solved-syntax-problem/#findComment-512860 Share on other sites More sharing options...
didster Posted April 9, 2008 Author Share Posted April 9, 2008 I have done it! Not sure how, dont even know what I have done differently. The code looks exactly the same and It isn't a refresh problem. I think that I just had some of the code ordered differently! It may have been a bug but not sure, very odd but thank you all for your help. Link to comment https://forums.phpfreaks.com/topic/100295-solved-syntax-problem/#findComment-512864 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.