Solved

Fatal error: Call to undefined function

Posted on 2004-09-02
8
622 Views
Last Modified: 2008-01-09
I get this error in my PHP code on a Windows NT server:
Fatal error: Call to undefined function: getmxrrwindows() in ...\formprocessor.php on line 219

On my linux machine, the code works.

I am working around the fact the PHP windows does not have a getmxrr() function.
So I have a version for windows, called getmxrrWindows().
The function declaration and call have a 'W' while the function specified in the error has a 'w',
which is mysterious.  What is the problem?

code snippets:

function validateEmail($email)
{
  // Create the syntactical validation regular expression
  $regexp = "^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})$";

  $valid = false; // assume it is not valid

  // if syntax is valid then
  if (eregi($regexp, $email))
  {

    list($username,$domaintld) = split("@",$email);  // get domain
    $os = strtoupper(substr(PHP_OS, 3));
    echo $os;  // 'NT' for NT machine, 'UX' for linux
    echo "<br>";
   
    // check if domain is valid using getmxrr()
    // getmxrr() is not available on windows platforms, so use home-grown version
    // if server is windows NT then
    if(substr_count(strtoupper(PHP_OS), 'NT'))
    {
      if (getmxrrWindows ($domaintld,$mxrecords) ) // ERROR HERE *****************************
      {
        $valid = true;
      }
    }
    else // server OS is not NT
    {
      if (getmxrr ($domaintld,$mxrecords) )
      {
        $valid = true;
      }
    }
  }

  return $valid;
}


function getmxrrWindows($hostname, &$mxhosts)
{
   $mxhosts = array();
   exec('nslookup -type=mx '.$hostname, $result_arr);
   foreach($result_arr as $line)
   {
     if (preg_match("/.*mail exchanger = (.*)/", $line, $matches))
         $mxhosts[] = $matches[1];
   }
   return( count($mxhosts) > 0 );
}  

0
Comment
Question by:allelopath
  • 3
  • 3
  • 2
8 Comments
 
LVL 27

Expert Comment

by:Diablo84
ID: 11963547
I seem to remember on Windows you must define the function before you call it so try moving the getmxrrWindows above the validateEmail function, you said the above is just code snippets so this may already be the case, if not i'd like you to try it.
0
 
LVL 1

Author Comment

by:allelopath
ID: 11963949
good idea.  getmxrrWindows() was indeed after validateEmail(), but I moved it and the error still occurs.
0
 
LVL 27

Expert Comment

by:Diablo84
ID: 11964162
hmm, i cannot recreate the error on my XP box, still thinking...
0
 
LVL 9

Expert Comment

by:_GeG_
ID: 11964278
hmm, is it possibe that you declare the function in the wrong context?
like
class xx{
function getmxrrWindows($hostname, &$mxhosts)
{...}
}

or function xxx{
...
function getmxrrWindows($hostname, &$mxhosts)
{...}
}

check your }s ;)
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 1

Author Comment

by:allelopath
ID: 11964602
GeG,
I understand why your 2nd example would be a problem and no, i''m not doing that.
I think my structure is like your 1st example, but i don't see why that's a problem.

I have:

<?php
...
// instantiate it here
$formProcessor = new FormProcessor();
...
class FormProcessor
{
...
function getmxrrWindows($hostname, &$mxhosts)
{
...
}
function validateEmail($email)
{
... // call to getmxrrWindows();
}
...
} // end class
?>
0
 
LVL 9

Accepted Solution

by:
_GeG_ earned 125 total points
ID: 11965121
then you will have to use $this->getmxrrWindows();
0
 
LVL 1

Author Comment

by:allelopath
ID: 11966663
Thanks, i was so focused on the "W" vs "w" thing, that i overlooked the real issue.
I guess Apache outputs messages in all lowercase.
In addition to referring to the function name in all lowercase, it did so with the path and filename, e.g. the filename is FormProcessor.php but it referred to as formprocessor.php in the error message.

Thanks, Diablo 84, for you input as well.
0
 
LVL 9

Expert Comment

by:_GeG_
ID: 11968827
no, it's not apache, I think it's a windows issue. I was also wondering when I saw my variables and paths in lowercase on command line php under windows, but I always thought wtf, so I still don't know why.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
PHP/Magento not logging 2 36
PHP_POST() error message 9 44
Sql query on a varchar that is numeric. 8 27
Session timeout 5 14
This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now