Quote Originariamente inviata da camionistaxcaso Visualizza il messaggio
Ma tipo postare il codice PHP?
E' lo stesso che ha postato alkatraz, quindi...

Comunque per completezza:
Codice PHP:
//  $id contiene l'identificazione dell'utente.
//  I dati passati al database arrivano via ajax e sono presi così:
$nickname filter_inputINPUT_POST'nickname'FILTER_CALLBACK, array( 'options' => 'verificaStringa' ));
$room filter_inputINPUT_POST'stanza'FILTER_CALLBACK, array( 'options' => 'verificaStringa' ));
$stringa utf8_decodefilter_inputINPUT_POST'stringa'FILTER_CALLBACK, array( 'options' => 'verificaStringa' )));
$colore filter_inputINPUT_POST'colore'FILTER_CALLBACK, array( 'options' => 'verificaStringa' ));
$background filter_inputINPUT_POST'background'FILTER_CALLBACK, array( 'options' => 'verificaStringa' ));
//  Connette al database, è una funzione remota in un altro file.
$conn PDOConnetti();
         if ( 
$id ){
            
//    Inserisce i dati nel database
            
$handle->closeCursor();
            
$sql 'INSERT INTO chat ( id_ute, stanza, frase, data_inserimento, colore, background )';
            
$sql .= 'VALUES ( :id, :room, :frase, CURDATE(), :col, :bkg );';
            
$handle $conn->prepare$sql );
            
$handle->bindValue':id', (int)$id['id_ute'], PDO::PARAM_INT );
                if ( 
$room === false || $room == ''$room 'generale';
            
$handle->bindValue':room'$roomPDO::PARAM_STR );
            
$handle->bindValue':frase'$stringaPDO::PARAM_STR );
                if ( 
$colore === false || $colore == ''$colore 'bianco';
            
$handle->bindValue':col'$colorePDO::PARAM_STR );
                if ( 
$background === false || $background == ''$background 'bg-bianco';
            
$handle->bindValue':bkg'$backgroundPDO::PARAM_STR );
            
$handle->execute();
        }
//  Presegue... 
L'unica differenza è stata che invece di usare CURRENT_TIMESTAMP ho usato CURDATE ed è stato l'errore, dato che CURDATE riporta solo la data, a volte funzionava e a volte no ( e questo è indubbiamente strano e mi ha indotto in errore )
Ora dato che CURRENT_TIMESTAMP è una funzione alias di NOW ho usato quest'ultima e sembra che stia funzionando.
Quindi la query è divenuta:
Codice PHP:
$sql 'INSERT INTO chat ( id_ute, stanza, frase, data_inserimento, colore, background )';
$sql .= 'VALUES ( :id, :room, :frase, NOW(), :col, :bkg );'