This is a discussion on "error in unsubscribe.php script" within the PHP Forum section. This forum, and the thread "error in unsubscribe.php script are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
error in unsubscribe.php script
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
error in unsubscribe.php script
i have this code below unsubscribe php script in which it occurs an error wen i run the script, please could any one help me solve this script.. thanks
error: Fatal error: Call to undefined function: delete_mail() in /home/simply22/public_html/test/mailing/unsubscribe.php on line 14
|
|
|
|
|||
|
Re: error in unsubscribe.php script
There is no delete_mail function in PHP, but you can define your own - either via the include file that's called in at the top of your script, or within your own script if you prefer.
|
|
|||
|
Re: error in unsubscribe.php script
I think your looking for the unset() function. e.g.
|
|
|||
|
Re: error in unsubscribe.php script
i use the unset function but it doesn't work here is the other code below for the function delete_mail()
|
|
|||
|
Re: error in unsubscribe.php script
I think I've seen the problem.
You called a function, specifying text as a parameter. Also, in your function you failed make reference to the parameter, so nothing would have been passed to the function to delete.
i.e.
Last edited by balaclave; Jul 19th, 2007 at 23:02. Reason: Fixing code. |
|
|||
|
Re: error in unsubscribe.php script
Balaclave has the better practice on handling this situation.. instead of calling the value from the $_POST pass it right to the function. But just for CSUN's information that since his function doesn't take any parameters (originally) from the way it looks he could have solved the problem by passing nothing.
delete_mail(); <? function delete_mail() { $email = $_POST['email']; //gets the value ################################################## ############# # if ($email == "") { # # $email = $_GET['email']; //is this line even needed? # # if you don't get a value from the $_POST (since i would # # assume you are posting this form, should this be an error # # Handler instead?) just a thought, # # # # If ($_POST['email'] != "" || NULL){ # # do something # # } # # else { # # Display error. # # } # # # ################################################## ############# $sql2="select * from mail where email='$email'"; $result2=mysql_query($sql2) or die("select fails"); $no=mysql_num_rows($result2); if ($no==0) { echo "Your email was not found in the list: " . LISTNAME; } else { echo "Your email was unsubscribed from the list: " . LISTNAME; } $sql2="delete from mail where email='$email'"; $result2=mysql_query($sql2) or die("unsubscribe failed, please try again"); } } ?> However as i said Bala has the right idea about the proper format, though i am unsure if just passing "$_POST" and "$_GET" will do what you want, your going to want to pass the email address it self. So you would probably rather pass: delete_mail($_POST['email']); i could be wrong. Last edited by dnhdevelopment; Jul 19th, 2007 at 17:34. |
|
|||
|
Re: error in unsubscribe.php script
Quote:
Except you can't have apostrophes in the $_GET or $_POST so you just have to use delete_mail($_GET[email]); So some working code would be:
Last edited by balaclave; Jul 19th, 2007 at 22:59. |
|
|||
|
Re: error in unsubscribe.php script
*ding* Next! |
![]() |
| Tags |
| unsubscribephp |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| members php script error | csun | PHP Forum | 2 | Jul 4th, 2007 06:46 |
| Ie Script error | acrikey | Starting Out | 2 | Mar 26th, 2007 14:22 |
| PHP Forgot password script error | eddie | PHP Forum | 4 | Mar 4th, 2007 15:43 |
| Another ASP script error message | a.jenery | Classic ASP | 13 | Apr 21st, 2006 01:10 |
| Php error when run script | jj1234 | PHP Forum | 3 | Feb 17th, 2006 13:27 |