Jump to content

php help


andre88uk

Recommended Posts

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 :D

Edited by andre88uk
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...