Jump to content


Photo

function help !!


  • Please log in to reply
8 replies to this topic

#1 devofash

devofash
  • Members
  • PipPipPip
  • Advanced Member
  • 81 posts

Posted 18 April 2006 - 12:59 AM

hello ppl got a question........ its quite silly one too *embarassed*

am trying to send an email after a query is updated..... but am getting an error saying :

Warning: mail() [function.mail]: SMTP server response: 554 Error: no valid recipients in C:\Program Files\xampp\htdocs\project\pending_job.php on line 131


here's the code below...... i think i need to pass $email into inform_user() but dont know how to ??

also can anyone suggest a better way of doing this..... it seems to me that i'm doing it the long way !!


     function pending()
     {
             // some stuff
     } 

        function update()
        {
            // update query    
         }

     function inform_user()
     {
      
        mail($email, $subject, $message,
          "From: ORS Webmaster<me@domain.com>\n
          X-Mailer: PHP/" . phpversion());
     }


#2 poirot

poirot
  • Members
  • PipPipPip
  • Advanced Member
  • 646 posts
  • LocationAustin, TX

Posted 18 April 2006 - 01:09 AM

It depends, you can use something like this:

function inform_user($email)
{
// code goes here
}

Or this:

function inform_user()
{
   global $email;
}

For further information, look for "Variable Scope" in the Manual.
~ D Kuang

#3 devofash

devofash
  • Members
  • PipPipPip
  • Advanced Member
  • 81 posts

Posted 18 April 2006 - 01:38 AM

it doesnt seem to work... !! *confused*



#4 poirot

poirot
  • Members
  • PipPipPip
  • Advanced Member
  • 646 posts
  • LocationAustin, TX

Posted 18 April 2006 - 02:02 AM

Well, you should make pending() return $email... Something like this:

function pending()
{
// do something

return $email;
}

function inform_user()
{
   global $email;
// do something
}

// calling the functions:

$email = pending();
inform_user();

~ D Kuang

#5 devofash

devofash
  • Members
  • PipPipPip
  • Advanced Member
  • 81 posts

Posted 18 April 2006 - 10:39 AM

ermmm need it to send email when a record gets updated..... and tht's why perviously i was calling the inform_user() inside the approve function .... how would i do tht ?

#6 inztinkt

inztinkt
  • Members
  • PipPip
  • Member
  • 21 posts
  • LocationCyprus ( OnThisIsland )

Posted 18 April 2006 - 11:47 AM

keep the same format as above,
only put the inform function above the update function,

also make the inform_user function ask for an email variable by calling...

function inform_user($email){ ...
instead of
function inform_user(){...

and then in function update simply call an email variable and pass it by calling inform_user($email);
<!-- // Blah // -->
OnThisIsland.com

The greatest leader is not always he who holds the most power, but he who has the ability to do the most with the power he has. - Inztinkt is Distinct!

#7 devofash

devofash
  • Members
  • PipPipPip
  • Advanced Member
  • 81 posts

Posted 18 April 2006 - 02:06 PM

ok so this is what i've done so far .... it sorta works..... here's the code
<?
     $link = $_GET['link'];
     if($link == approve)
     {
       echo approve();
     }

     function pending()
     {
       // some stuff

        <td> <a href = \"?page=pending_job&link=approve&jobID=$jobID\"> 
       Approve </a></td>
       return $email;
     }

     function inform_user($email)
     {
       global $email;

          $subject = "blah";
          $message="blah";

       mail($email, $subject, $message,
          "From: ORS Webmaster<me@somedomain.com>\n
           X-Mailer: PHP/" . phpversion());
           echo "Mail has been sent";
     }

     function approve()
     {
       global $email;
           // update record
       if($result)
       {
         echo $email;
         inform_user($email);
       }
     }

     $email = pending();
     inform_user($email);   
?>

i want it to send email to a person who's record is updated, after i press the approve link (thts when the record gets updated)

right now it just send an email to the last entry every time page is refreshed.

#8 inztinkt

inztinkt
  • Members
  • PipPip
  • Member
  • 21 posts
  • LocationCyprus ( OnThisIsland )

Posted 18 April 2006 - 05:39 PM

easiest way from wat i can see is parse $email into the link field, so add &email=$email in the link...
assuming the rows are being parsed thru a 'while' each link shuld have a different email value,

when doing a check for $link==approve,
set $email = $_GET['email']
<!-- // Blah // -->
OnThisIsland.com

The greatest leader is not always he who holds the most power, but he who has the ability to do the most with the power he has. - Inztinkt is Distinct!

#9 devofash

devofash
  • Members
  • PipPipPip
  • Advanced Member
  • 81 posts

Posted 18 April 2006 - 06:31 PM

that works :) ......... but what if i want to pass more then one variable ....say for e.g. i want to pass 10 variables.... then it would be a little u know...

for now it works though.... if anyone has a solution plz lemme know :D




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users