I'm having problems with this error and I can not tell why it is.
The error is as follows:
On the one hand I have a form
which sends various data per POST
, including a date. I receive the information in another PHP file where I process other data but I do not change the date. Then I create the object articulo
, which among other things has the date, and I call the function altaArticulo
, which makes an INSERT.
Inside the function I use the functions get
to obtain the data of the object. All data arrive well minus the date which is null
.
This is my code:
$fecha_inicio = strip_tags($_POST['fecha_inicio']); //dd-mm-yy
$fecha_inicio = date("Y-m-d", strtotime($fecha_inicio));
// Usando die(var_dump($fech_inicio) acá la variable tiene la fecha guardada correctamente
//Creo el objeto publicacion
$p = new art_pub('',$id_articulo_ingresado,$id_usu,$fecha_inicio,$fecha_fin,$tipo_publicacion);
$q = $p->altaPublicacion($conex);
Function of registration in the class file:
public function altaPublicacion($conex){
$id_art=$this->getIdArt();
$id_usu=$this->getIdUsu();
$fecha_inicio->getFechaInicio();// En esta linea da el error
$fecha_fin->getFechaFin();
$tipo->getTipoVenta();
$sql = "INSERT INTO 'publica' ('fecha_in','fecha_fin','tipo','id_u','id_a')
VALUES (:fecha_inicio, :fecha_fin, :tipo, :id_usu, :id_art)";
$result = $conex->prepare($sql);
$result->execute(array(':fecha_inicio'=>$fecha_inicio, ':fecha_fin'=>$fecha_fin,':tipo'=>$tipo
, ':id_usu'=>$id_usu, ':id_art'=>$id_art));
// Guardo el id de la publicacion luego de insertar para redirigir a la publicacion finalizada
$id_publicacion = $conex->lastInsertedId();
return ($id_publicacion);
}
I do not realize because he does not receive the data. Why can it be and how can I solve it?