I have an array that is generated when choosing items from a multiple select. In the process of recording data I do this:
if (isset($_POST['temas_event'])) {
$temas_event = json_encode($_POST['temas_event']);
} else {
$temas_event = ['0'];
}
What I have noticed is that although in the base it is defined as the default value "NULL" there are times that if I do not select anything in the multiple select, in the database it records the word "Array" with the consequent ones problems that I generate when reading the records ... that is to say that my definition of the registry ignores it or is ill-defined. What do you suggest I can do?
The recording process is done as:
$conexion = new Conexion();
$stmt = $conexion -> prepare("UPDATE usuarios_full SET nombre_event = :nombre_event, dom_event = :dom_event, lat_event = :lat_event, lng_event = :lng_event, web_event = :web_event, tel_event = :tel_event, alcance_event = :alcance_event, temas_event = :temas_event, cert_event = :cert_event, event_pagos = :event_pagos WHERE idusuario = :valor");
$stmt->bindValue(":valor", $idusuario);
$stmt->bindValue(":nombre_event", $nombre_event);
$stmt->bindValue(":dom_event", $dom_event);
$stmt->bindValue(":lat_event", $lat_event);
$stmt->bindValue(":lng_event", $lng_event);
$stmt->bindValue(":web_event", $web_event);
$stmt->bindValue(":tel_event", $tel_event);
$stmt->bindValue(":alcance_event", $alcance_event); (*******)
$stmt->bindValue(":temas_event", $temas_event); (*******)
$stmt->bindValue(":cert_event", $cert_event);
$stmt->bindValue(":event_pagos", $event_pagos);
$stmt->execute();
if ($stmt->rowCount() > 0) {
$resultado = 1;
} else {
$resultado = NULL;
}
where (*******) are arrays