Ver Mensaje Individual
  #1 (permalink)  
Antiguo 15/01/2015, 08:39
festrada72
 
Fecha de Ingreso: enero-2015
Mensajes: 4
Antigüedad: 9 años, 3 meses
Puntos: 0
problemas con funciones

Hola, tengo un problema con las funciones y no se a que se debe.
Tengo esta funcion

function updatetrabajador($datos){

$sqlU = "UPDATE trabajadores set Tlfno_Oficial = ".$datos[4]." WHERE id_trabajador=" .$datos[0];

try {
$rec = $con->query($sqlU);
return true;
}
catch(PDOException $e)
{
echo $sqlU . "<br>" . $e->getMessage();
return false;
}

}


la funcion esta en el propio fichero, la tenia en otro pero para descartar cosa la puse en el propio fichero y hago la llamada aqui

if(!$errores){
$datos = array($_POST['id_trabajador'], GetSQLValueString( $_POST['DNI'], 'text'), GetSQLValueString( $_POST['Apellidos'], 'text'),
GetSQLValueString( $_POST['Nombre'], 'text'), GetSQLValueString( $_POST['Tlfno_Oficial'], 'int'), GetSQLValueString( $_POST['Tlfno1'], 'int'),
GetSQLValueString( $_POST['Tlfno2'], 'int'), GetSQLValueString( $_POST['email'], 'text'),
GetSQLValueString( $_POST['Fecha_Nacimiento'], 'date'), GetSQLValueString( $_POST['Fecha_Jubilacion'], 'date'), GetSQLValueString( $_POST['Direccion'], 'text'),
GetSQLValueString( $_POST['Localidad'], 'text'), GetSQLValueString( $_POST['CP'], 'text'), GetSQLValueString( $_POST['Informacion'], 'text') );


updatetrabajador($datos); // llamada a la funcion
}


Si hago eso no funciona,

y si en lugar de la llamada a la funcion pongo la consulta:

$sqlU = "UPDATE trabajadores set Tlfno_Oficial = ".$datos[4]." WHERE id_trabajador=" .$datos[0];

try {
$rec = $con->query($sqlU);
header('Location: guardatrabajador.php?id='.$_POST['id_trabajador']);
return true;
}
catch(PDOException $e)
{
echo $sql . "<br>" . $e->getMessage();
return false;
}


Si me lo ejecuta correctamente.
Alguien puede decirme que estoy haciendo mal.
gracias por adelantado.