devofash Posted April 18, 2006 Share Posted April 18, 2006 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 131here'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 !![code] 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()); }[/code] Quote Link to comment Share on other sites More sharing options...
poirot Posted April 18, 2006 Share Posted April 18, 2006 It depends, you can use something like this:[code]function inform_user($email){// code goes here}[/code]Or this:[code]function inform_user(){ global $email;}[/code]For further information, look for "Variable Scope" in the Manual. Quote Link to comment Share on other sites More sharing options...
devofash Posted April 18, 2006 Author Share Posted April 18, 2006 it doesnt seem to work... !! *confused* Quote Link to comment Share on other sites More sharing options...
poirot Posted April 18, 2006 Share Posted April 18, 2006 Well, you should make pending() return $email... Something like this:[code]function pending(){// do somethingreturn $email;}function inform_user(){ global $email;// do something}// calling the functions:$email = pending();inform_user();[/code] Quote Link to comment Share on other sites More sharing options...
devofash Posted April 18, 2006 Author Share Posted April 18, 2006 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 ? Quote Link to comment Share on other sites More sharing options...
inztinkt Posted April 18, 2006 Share Posted April 18, 2006 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); Quote Link to comment Share on other sites More sharing options...
devofash Posted April 18, 2006 Author Share Posted April 18, 2006 ok so this is what i've done so far .... it sorta works..... here's the code[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); ?>[/code]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. Quote Link to comment Share on other sites More sharing options...
inztinkt Posted April 18, 2006 Share Posted April 18, 2006 easiest way from wat i can see is parse $email into the link field, so add [b]&email=$email[/b] 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'] Quote Link to comment Share on other sites More sharing options...
devofash Posted April 18, 2006 Author Share Posted April 18, 2006 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 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.