$mysqli = new mysqli( 'localhost', 'user', 'password', 'database' );
if ( $stmt = $mysqli->prepare( 'INSERT INTO comments( `note`, `name`, `text`, `date` ) VALUES( ?, ?, ?, ? )' ) ) {
$id = 1;
$name = $_POST[ 'namecomment' ];
$text = $_POST[ 'inputcomment' ];
$date = date( 'Y-m-d H:i:s' );
$stmt->bind_param( 'isss', $id, $name, $text, $date );
$stmt->execute();
} else {
echo $mysqli->error . PHP_EOL;
}
$mysqli->close();