I am trying to use the code below to do the following;
-
In a MySQL table called submission,
check to see if subcheck = 1 for the
row wheresubmissionid =.
$submissionid -
If the answer to #1 above is yes, then take the
emailfield from a MySQL table called “login” from the row where username = $submittor’, and then email$commentto that address.
It’s not working. Any ideas why not?
Thanks in advance,
John
$querye = mysql_query("SELECT subcheck FROM submission WHERE subcheck = '1' AND WHERE submissionid = '$submissionid' ");
if (mysql_num_rows($querye) == 1)
{
$mailaddress = "SELECT email FROM login WHERE username = '$submittor'";
$queryem = mail($mailaddress, "Someone has commented on your submission $submission.", $comment, "no-reply@domain.com");
mysql_query($queryem) or die(mysql_error());
}
else
{
//your subcheck is not 1 / nothing was found
}
You are using
$mailaddresbefore fetching it from DB.You should do something like: