trn579s Posted February 13, 2007 Share Posted February 13, 2007 I just installed php4.4.3/mysql4.1.21/apache1.3.37 on my local machine and have run into a snag. I am getting the following error when I try to call one of my own user defined functions (Fatal error: Call to undefined function: verifyEmail() in C:\xampp\htdocs\Guar...) verifyEmail is a function that I wrote, and works just fine on my production server, but not on my local machine setup... which has all the same versions of php, mysql, and apache. verifyEmail is in an include file that is being read correctly (I tested it with a <?php print "test"; ?> and got a result) So, here is my function call: $valid = verifyEmail($EmailAddress); Here is my function in the includes file: function verifyEmail ($testString) { // Check for a valid email address return (eregi("^([[:alnum:]]|_|\.|-)+@([[:alnum:]]|\.|-)+(\.)([a-z]{2,4})$", $testString)); } Anyone have a clue as to what stupid mistake I am making? I have spent all day tinkering with php and apache settings and everything in between. Thanks, Tom Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 13, 2007 Share Posted February 13, 2007 The includes file isn't being included. Use require() to make sure. Quote Link to comment Share on other sites More sharing options...
trn579s Posted February 13, 2007 Author Share Posted February 13, 2007 That would be my first thought too... but I can put a print statement in that includes file, and it shows up.... worked under both includes and require. Strange, Huh? Quote Link to comment Share on other sites More sharing options...
trn579s Posted February 13, 2007 Author Share Posted February 13, 2007 I have matched all php.ini settings to that on my production server. So there should be no surprises there. The only thing that has changed is the inclusion of PEAR. Quote Link to comment Share on other sites More sharing options...
btherl Posted February 13, 2007 Share Posted February 13, 2007 Have you tried a print statement right before and after the function definition? I would also check whether or not other included functions are working normally. Quote Link to comment Share on other sites More sharing options...
trn579s Posted February 13, 2007 Author Share Posted February 13, 2007 Yep. I can fire a print statement in the includes file before and after my function. NEW DEVELOPMENT - If I put the function on the same page as my code (instead of using an include file) it works just fine. I have been over and over the syntax on the files, and everything is good there. Any ideas on what would cause that error 'undefined function' when I try to call it from an includes file, but not when I call it from within the same page. Note: I do have register_global on. Thanks, Tom Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted February 13, 2007 Share Posted February 13, 2007 the path is wrong in your include... I always start with $_SERVER['DOCUMENT_ROOT'] in any include or require construct. Quote Link to comment Share on other sites More sharing options...
trn579s Posted February 13, 2007 Author Share Posted February 13, 2007 I have it linked up correctly, and can fire a print from the included file right above the function. Quote Link to comment Share on other sites More sharing options...
trn579s Posted February 13, 2007 Author Share Posted February 13, 2007 Is there some setting in Apache of PHP that prevents calling a user defined function, or requires it to be specified differently that I have specified it? Here is my include and call to the function: include $includesPath."validation_functions.php"; $valid = verifyEmail($EmailAddress); And here is my function in the included file: function verifyEmail ($testString) { // Check for a valid email address return (eregi("^([[:alnum:]]|_|\.|-)+@([[:alnum:]]|\.|-)+(\.)([a-z]{2,4})$", $testString)); } Quote Link to comment Share on other sites More sharing options...
trn579s Posted February 13, 2007 Author Share Posted February 13, 2007 I was using xampp for my php/apache/mysql which was causing the mysterious issue. I am not using WAMP5 and everything is up and running. Thanks to all who replied, and happy coding. 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.