tags:

views:

45

answers:

4

The below gives me a fatal error saying that "mymail" was not found.

Any ideas why? Looks right to me.

mailreq.php

include("mail.php");
$r = mymail("test","test");

mail.php

function mymail($body, $reqtype)
{
 //blah blah
}

EDIT: For some reason, this version of php doesn't see <? ?> as valid shorthand tags. I changed it to <?php ?> and it sees the functions now.

A: 

You're either not passing the correct path of mail.php or there is no mymail function in mail.php. What are the absolute paths of mail.php and mailreq.php?

It appears your script requires mail.php, so use require 'mail.php' (or whatever the correct path is).

webbiedave
mail.php and mailreq.php are all in the same directory.Using WAMPServer if that makes any difference.
bobber205
A: 

The reason why you are getting the error ... was not found. is most likely because you are not specifying the correct path for the mail.php. Make sure that you are specifying the correct path.

Sarfraz
+4  A: 

If mymail() wasn't found, the problem is presumably with the path to the included file. You might try using require() instead, that way the script will (if I remember rightly) stop running if the required file isn't found.

David Thomas
Or, better, `require_once()`, which only includes it once. And yes, using `require` rather than `include` will throw a fatal error if it can't include it.
Slokun
@Slokun, absolutely, I was only using it as part of the debug process, rather than as an option for clean code =) But it's a good point.
David Thomas
+2  A: 

I can't see anything wrong with what you posted. Are you sure it wasn't some little mistake somewhere - like maybe you forgot the <?php and ?> in the mail.php file? Or maybe a pathing issue?

Eric Petroelje
Interesting. He should see the output though.
webbiedave