caliray Posted November 30, 2014 Share Posted November 30, 2014 I have a bit of php code to send me an email when someone logs in to my site. I want to include the person's name and two other bits from my database, but I can't get the formatting correct. I keep getting errors when I try to load the page. Here's the code which obviously has mistakes. The first code works, it's the second one that does not work for the $message line . if (mysql_num_rows($exe) == 1) { $message_m = "Someone with RefCode ".$RefC." has viewed the homepage for the first time."; mail("ray.fellers@gmail.com", "Good News! Someone just logged in to view the home page", $message_m); setcookie("has_entered_correct_refcode", "true", time()+27000000, "/"); setcookie("has_entered_correct_refcode_value", $_POST["refcode"], time()+27000000, "/"); header("Location: /index.php"); die(); if (mysql_num_rows($exe) == 1) { $message_m =" "'.$_POST['fname'].'," with RefCode "'.$RefC.'," and refund amount of "'.$_POST['refvalact'].'," has viewed the homepage."; mail("ray.fellers@gmail.com", "Good News! Someone just logged in to view the home page", $message_m); setcookie("has_entered_correct_refcode", "true", time()+27000000, "/"); setcookie("has_entered_correct_refcode_value", $_POST["refcode"], time()+27000000, "/"); header("Location: /index.php"); die(); } Thanks for any help to resolve this. Quote Link to comment Share on other sites More sharing options...
Barand Posted November 30, 2014 Share Posted November 30, 2014 Your single quotes and commas need to be inside the double quotes, not outside. Quote Link to comment Share on other sites More sharing options...
caliray Posted November 30, 2014 Author Share Posted November 30, 2014 Your single quotes and commas need to be inside the double quotes, not outside. This is a snippet from the code. "'.$_POST['fname'].'," so what do you mean the single quotes and commas need to be inside the double quotes? Could you please write an example so I can see the difference? Thanks. Quote Link to comment Share on other sites More sharing options...
Solution Barand Posted November 30, 2014 Solution Share Posted November 30, 2014 Precisely that. EG $message_m ="'" . $_POST['fname'] . "', with RefCode '" . $RefC . "', and .... "; Alternatively, don't use concatenation if it's confusing you $message_m = "'{$_POST['fname']}', with RefCode '$RefC', and .... "; Quote Link to comment Share on other sites More sharing options...
caliray Posted November 30, 2014 Author Share Posted November 30, 2014 Precisely that. EG $message_m ="'" . $_POST['fname'] . "', with RefCode '" . $RefC . "', and .... "; Alternatively, don't use concatenation if it's confusing you $message_m = "'{$_POST['fname']}', with RefCode '$RefC', and .... "; OK, I see what you mean. Thanks. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.