Error using onBeforeInsert or onBeforUpdate

Hi, everybody… sorry my english is poor…

My application use onBeforeInsert and onBeforeUpdate event.

this is code:
$vtra = {tra_id};
$vdes = {aus_desde};
$vhas = {aus_hasta};

$vresul = validar_ausencia($vtra, $vdes, $vhas);

if ($vresul==true)
{
sc_error_message(“ERROR: Ya existe un registro que contempla uno o mas dias del rango de fechas indicado, revise las fechas…”);
return false;
}


The validar_ausencia procedure have this code:

$xxdes = date(‘Y-m-d’,strtotime($xdes));
$xxhas = date(‘Y-m-d’,strtotime($xhas));

$xsql = “SELECT 1 FROM ausencia WHERE tra_id = '”.$xtra."’ and "
."(’".$xxdes."’ >= aus_desde and ‘".$xxdes."’ <= aus_hasta) "
.“or (’”.$xxhas."’ >= aus_desde and ‘".$xxhas."’ <= aus_hasta) ";

sc_select(xmy_data,$xsql);
if ({xmy_data} === false)
{
echo "Error en (validar_ausencia) = ".{xmy_data_erro};
}
else
{
$xval = false;
if (!$xmy_data->EOF)
{
$xval = true;
}
$xmy_data->Close();
}
return $xval;

when shooting the event and displays the message appears:

ERROR: Ya existe un registro que contempla uno o mas dias del rango de fechas indicado, revise las fechas…
Undefined property: form_ausencia_ini::$page
Undefined variable: nm_cor_fun_cel
Undefined variable: nm_img_fun_cel
Undefined property: form_ausencia_apl::$scFormFocusErrorName

But if I use this code in onValidate event not happens this error. Only appears my message “Error: …revise las fechas…” I need this code only onBeforeInsert and onBeforeUpdate not when deleted record.

Can someone help me??

$vresul = validar_ausencia($vtra, $vdes, $vhas);

this routing validar_ausencia, where is it declared? Is it in the library or a php method? Are you passing parameters? I have bad experiences using fieldnames in procedures, I useually pass them in the header.

Prueba validarlo en el Onvalidate.