andre88uk Posted February 22, 2009 Report Share Posted February 22, 2009 (edited) have the following code: function email_subscribers($tid,$post_id){ $sql = "SELECT thread_title FROM forum_threads WHERE thread_id = '" . $tid . "'"; $result = mysql_query($sql); $result = mysql_fetch_array($result); $thread_name = $result['thread_title'];//Get the title here $post_name = get_user_name_from_id($post_id); //Right we have the info shite $sql = "SELECT * FROM `forum_subscriptions` WHERE `tid` = '" . $tid . "' && `notified` = '0';"; echo $sql; $result = mysql_query($sql); echo " "; while ($row = mysql_fetch_array($result)) { print_r($row); $sql = "SELECT `user_name_unused`, `user_email` FROM date_profiles WHERE user_id = '" . $row['uid'] . "';"; $result = mysql_query($sql); $result = mysql_fetch_assoc($result); $Name = "Forum Subscriptions"; //senders name $email = "subscriptions@partipeeps.com"; //senders e-mail adress $recipient = $result['user_email']; //recipient $mail_body = "Hey " . $result['user_name_unused'] . ", \nThere has been a reply to a thread you are subscribed to entitled: \n" . $thread_name . " \nReponse posted by : " . $post_name . " \nYou will not recieve any more email notifications to this thread until you next log in"; //mail body $subject = "Subscription alert : " . $thread_name; //subject $header = "From: ". $Name . " <" . $email . ">\r\n"; //optional headerfields mail($recipient, $subject, $mail_body, $header); //mail command /*$sql = "UPDATE forum_subscriptions SET `notified` = '1' WHERE `uid` = '" . $row['uid'] . "' && `tid` = '" . $tid . "';"; if(!mysql_query($sql)){ echo mysql_error(); }*/ } } when run it only gets the first line for the results and nothing more. also returns the error : Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/partipee/public_html/forum/reply_do.php on line 126 Line 126 is while ($row = mysql_fetch_array($result)) { Muchio gracias in advance Edited February 22, 2009 by andre88uk Quote Link to comment Share on other sites More sharing options...
monkeysaurus Posted February 22, 2009 Report Share Posted February 22, 2009 Hi Andre, You need to remove the following line: $result = mysql_fetch_array($result); There's no need for it to be there with the second while($row = mysql_fetch_array($result)). Let me know if that works for you. Quote Link to comment Share on other sites More sharing options...
andre88uk Posted February 22, 2009 Author Report Share Posted February 22, 2009 The first $result = mysql_fetch_array($result); is for the thread name and stuff so doesnt affect that lower part... it seems its : $sql = "SELECT * FROM `forum_subscriptions` WHERE `tid` = '" . $tid . "' && `notified` = '0';"; echo $sql; $result = mysql_query($sql); echo " "; while ($row = mysql_fetch_array($result)) { That is the error but echo $sql returns: SELECT * FROM `forum_subscriptions` WHERE `tid` = '3980' && `notified` = '0'; Which is correct.. there are definitely two rows in the table 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.
Note: Your post will require moderator approval before it will be visible.