what i am trying to do is send weekly updates of new members (those who signed up within the past 7 days) to existing members of my database. the new member information would be sent to those existing members that have the same city and genre_select of the new members.
i am attempting the queries in 3 steps.
1)select the city and genre of entries in the database that have been created in the past 7 days. $newartist query
2)match these cities and genres of already existing members that have answered YES to receive the updates. $result query
3)collects the new member information and sends this information to the existing artists that have the same city and genre of the new artists. $emailresult query
Here is the code:
$newartist = mysql_query("SELECT Distinct City, Genre_Select FROM Musicians_Network WHERE Date_Created > curdate()-7", $db);
if ($myfirstrow = mysql_fetch_array($newartist)) {
do {
$result = mysql_query("SELECT Contact FROM Musicians_Network WHERE (City = ".$myfirstrow['City']." or Genre_Select = ".$myfirstrow['Genre_Select'].") and Updates = 'Yes'",$db);
$emailresult = mysql_query("SELECT Artist_Name, City, State_or_Province, Country, Genre_Select, Genre_Enter Artist_Function, Homepage FROM Musicians_Network WHERE (City = ".$myfirstrow['City']." or Genre_Select = ".$myfirstrow['Genre_Select'].") and Date_Created > curdate()-7", $db);
if ($myrow = mysql_fetch_array($emailresult)) {
do {
$update_email = $update_email.",".$myrow["Contact"];
} while ($myrow = mysql_fetch_array($emailresult));
}
}while ($myrow = mysql_fetch_array($newartist));
$update_recipient = $update_email;
$update_subject = "A new artist in your city or genre has been added";
$update_message = "Artist Name: $Artist_Name
Location: $City, $State_or_Province, $Country
Genre: $Genre_Select, $Genre_Enter
Function: $Artist_Function
Homepage: $Homepage";
$update_extra = "From: Boggle_Productions<>\r\nReply-To: ()\r\n";
mail ($update_recipient, $update_subject, $update_message, $update_extra);
everytime i try to run this, i get an error:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/bogglepr/public_html/weeklyupdate.php on line 20
which refers to the last line in the $emailresult query around Date_Created > curdate()-7. i am on a serious deadline and don't know what to do. can someone please help me?