I have the following function in PHP
that receives a date and a id_persona
, which searches in a table of the database if there already exists a record with that date and with that id_persona
. It works well, only that I need it to be recursive and when I call it again in case it enters if
the date should change.
I add a day to it and I send it to the function devuelve_fecha_q()
but now that date I received it I have to check again and call the function again and send me a syntax error.
If I mention the line where I call the function again, it works well and the modified date is returned to me.
For example I have 2017-02-15
and that date exists, then I return 2017-02-28
and it ends but I need that last date to verify it and so n times until I can not find the date, then it would end and I would return the date.
protected function verifica_fecha_nomina ($id_persona,$fecha_a_verificar) {
$sql_verifica_nomina = "SELECT DISTINCT
pn.fecha_fin
FROM
personal_nomina_detalle pnd
INNER JOIN
personal_nomina pn ON pn.id_nomina = pnd.id_nomina
WHERE
pnd.id_persona = $id_persona AND pn.fecha_fin = '$fecha_a_verificar'";
$res_verifica_nomina = mysql_query($sql_verifica_nomina)or die("¡Error al obtener la fecha verificación nomina! $sql_verifica_nomina".mysql_error());
$respuesta_verifica_nomina = mysql_num_rows($res_verifica_nomina);
if ($respuesta_verifica_nomina > 0 && $respuesta_verifica_nomina !== null && $respuesta_verifica_nomina !== '') {
$fecha_a_verificar = date("Y-m-d", strtotime($fecha_a_verificar."+ 1 days"));
$fecha_a_verificar = devuelve_fecha_q($fecha_a_verificar);
verifica_fecha_nomina($id_persona,$fecha_a_verificar);
// echo "El numero de registros con esa fecha es: ".$respuesta_verifica_nomina.$fecha_a_verificar;
}
return $fecha_a_verificar;
}
Error in firebug: