Re: undefined function error with lost password script
| From: | Robin Vickery | Date: | Thu, 23 Mar 2006 11:44:16 +0000 |
| Subject: | Re: undefined function error with lost password script | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-232448@lists.php.net to get a copy of this message | ||
On 23/03/06, Mark <neretlis@westnet.com.au> wrote:
> Can anyone see a problem with this at a glance. I think i have pushed my
> luck with this forum ( inc. Chris)of late but i paid a lot of money for this
> script and it has a few bugs.
>
> THis is what i get returned---
> Fatal error: Call to undefined function: recover_pw() in
> /home/realt905/public_html/lost_pw.php on line 70
>
> where line 70 is : recover_pw($_POST['email_address']);
>
>
> ********************************
> <?php
> include("connect.php");
>
> if (isset($_POST['Submit'])) {
>
> [...]
> recover_pw($_POST['email_address']);
>
> function recover_pw($email_address){
> [...]
> }
Normally it doesn't matter if you define a function before or after
you use it., but you're defining the function conditionally - if
$_POST['Submit'] isn't set then recover_pw() will not be defined. In
that case you have to make sure it's defined before it's used.
The manual tells you that.
http://au.php.net/manual/en/language.functions.php
The solution is to take the function definition out if the if-block.
-robin