Jump to content

Call to undefined function.


bigboss

Recommended Posts

Hello, I am writing a validate function that works by passing the post value, the type of field and if the field is required. In my register page I call the function like:

 

<?php
validate($_POST['username'],'username',1);
?>

 

The function is stored in a separate functions page in a functions directory. The code for the function is as folllows:

 

<?php 
function validate($post_value,$field_type,$required){
if(isset($_POST[$post_value]) && (!empty($post_value)) || !$required){

}else{

}
?>

 

I have included the functions page with

 

<?php
include 'functions/functions.php';
?>

 

But yet when I debug or run the code it seems as if my code can't see the function even though it enters the functions.php file. Have you guys got any ideas why this would be happening?

Link to comment
https://forums.phpfreaks.com/topic/149794-call-to-undefined-function/
Share on other sites

Your function is wrong anyway.

 

It should read.

 

function validate($post_value,$field_type,$required)
{
if(isset($post_value) && !empty(trim($post_value)) || !$required)
        {

}
        else
        {

}
}

 

This might in turn fix the problem so worth a try :).

I would like to have a validation class, but the only OOP experience I've had in the past is Java. I'm not sure how PHP implements polymorphism, inheritance and encapsulation. This project is only for a small website and it is easier for me to code a small function that to learn OOP rules in PHP and then code a class.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.