Jump to content

Call to undefined function validatename() in


dc_jt

Recommended Posts

Hi

Im trying to validate the name field so that no numbers can be inputted. Here is my function in my Clients table class:

[code]private function ValidateClientData($aPostData)
{
$aErrors = array();

if(validatename($aPostData['Name'])===false)
{
$aErrors['Name']='Please enter your Name';}

if(validateemail($aPostData['Email'])===false)
{
$aErrors['Email']='Please enter a valid Email address';}
//if(validateemail(!$aPostData['Email'])===false)
//{
// $aErrors['Email']='Please enter your Email';
//}
if(!$aPostData['Address'])
{
$aErrors['Enquiry']='Please enter your Address';
}
if(!$aPostData['Business_Name'])
{
$aErrors['Business_Name']='Please enter your Business Name';
}
if(!$aPostData['Type_of_Business'])
{
$aErrors['Type_of_Business']='Please enter your Type of Business';
}


if (count($aErrors) > 0) return array(false, $aErrors);

return array(true);
}


}
?>[/code]

I then have a globals file which contains the 'validatename' function:

[code]function validate_email ($email)
{
if(ereg('^[_a-z0-9A-Z+-]+(\.[_a-z0-9A-Z+-]+)*@[a-z0-9A-Z-]+(\.[a-z0-9A-Z-]+)*$', $email))
{
return true;
}
  else
{
    return false;
}
}

function validateemail ($email)
{
return validate_email($email);

function validate_name ($name)
{
if(ereg("/^[a-zA-Z\-\Ä\ä\Ö\ö\Ü\ü\s]+$/s", $name))
{
return true;
}
  else
{
    return false;
}

}
function validatename ($name)
{
return validate_name($name);
}[/code]

As you can see its exactly the same as the email function except the characters that are accepted.

I get the error
Fatal error: Call to undefined function validatename() in /mnt/k/*****/website/_lclasses/Tables/RCLTblClients.class.php on line 35

Anyone know why?

Thanks
Link to comment
Share on other sites

[code]<?php

require_once(LOCAL_CLASSES.'/RCLDbBase.class.php');
require_once(GLOBALS.'global_fns.php');

class RCLTblClients extends RCLDbBase

{
protected $sTableName = "clients";

public function AddClient($aPostData)
{
$aReturn = $this->ValidateClientData($aPostData);

if (!$aReturn[0])
{
return $aReturn;
}

$sSql = "INSERT INTO $this->sTableName SET
name = '$aPostData[Name]',
email = '$aPostData[Email]',
address = '$aPostData[Address]',
business_name = '$aPostData[Business_Name]',
type_of_business = '$aPostData[Type_of_Business]',
comments ='$aPostData[Comments]' ";

return array(mysql_query($sSql, $this->oDb->GetConnection()));
}

private function ValidateClientData($aPostData)
{
$aErrors = array();

if(validatename($aPostData['Name'])===false)
{
$aErrors['Name']='Please enter your Name';}

if(validateemail($aPostData['Email'])===false)
{
$aErrors['Email']='Please enter a valid Email address';}
//if(validateemail(!$aPostData['Email'])===false)
//{
// $aErrors['Email']='Please enter your Email';
//}
if(!$aPostData['Address'])
{
$aErrors['Enquiry']='Please enter your Address';
}
if(!$aPostData['Business_Name'])
{
$aErrors['Business_Name']='Please enter your Business Name';
}
if(!$aPostData['Type_of_Business'])
{
$aErrors['Type_of_Business']='Please enter your Type of Business';
}


if (count($aErrors) > 0) return array(false, $aErrors);

return array(true);
}


}
?>[/code]

Line 35 which is below is whats causing the problem:

if(validatename($aPostData['Name'])===false)
Link to comment
Share on other sites

My mistake I posted the wrong global above. Here is the correct one:

[code]function validate_email ($email)
{
if(preg_match('^[_a-z0-9A-Z+-]+(\.[_a-z0-9A-Z+-]+)*@[a-z0-9A-Z-]+(\.[a-z0-9A-Z-]+)*$', $email))
{
return true;
}
  else
{
    return false;
}
}

function validateemail ($email)
{
return validate_email($email);

function validate_name ($name)
{
if(ereg("/^[a-zA-Z\-\Ä\ä\Ö\ö\Ü\ü\s]+$/s", $name))
{
return true;
}
  else
{
    return false;
}

}
function validatename ($name)
{
return validate_name($name);[/code]

So I do have a validatename function
Link to comment
Share on other sites

I think I found it...

[code]

<?php

function validate_email ($email)
{
if(preg_match('^[_a-z0-9A-Z+-]+(\.[_a-z0-9A-Z+-]+)*@[a-z0-9A-Z-]+(\.[a-z0-9A-Z-]+)*$', $email))
{
return true;
}
  else
{
    return false;
}
}

function validateemail ($email)
{
return validate_email($email);
} // THIS WAS MISSING

function validate_name ($name)
{
if(ereg("/^[a-zA-Z\-\Ä\ä\Ö\ö\Ü\ü\s]+$/s", $name))
{
return true;
}
  else
{
    return false;
}

}

function validatename ($name)
{
return validate_name($name);
} // THIS WAS MISSING

?>

[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.