dit problem er at du skal convaterer stringen til en datetime og dit / og / giver problemer med strtotime
en anden løsning er kunne være at bruge NOW()
http://php.net/manual/en/function.strtotime.phphttp://stackoverflow.com/questions/2891937/strtotime-doesnt-work-with-dd-mm-yyyy-formattest db
CREATE TABLE IF NOT EXISTS `tbl_test` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`Navn` varchar(255) COLLATE utf8_danish_ci NOT NULL,
`Dato_op` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_danish_ci AUTO_INCREMENT=3 ;
INSERT INTO `tbl_test` (`id`, `Navn`, `Dato_op`) VALUES
(1, 'ronny', '2013-03-11 07:36:18'),
(2, 'heidi', '2013-07-01 00:00:00');
test php
<?php
include_once($_SERVER['DOCUMENT_ROOT']."/include/php/debugheader.php"); // slår fejl visning til/fra
require_once('Connect.php'); // Indeholder mit database connect.
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
</style>
<script type="text/javascript">
</script>
</head>
<body>
<?php
if(isset($_POST['send'])){
// brug af NOW istedet
$Navn = "prøve";
$sql ="UPDATE tbl_test SET Navn='$Navn', Dato_op=NOW() WHERE id=2";
$rs =$conn->query($sql) or die ( mysqli_error($conn));
// studer denne start
// http://stackoverflow.com/questions/2891937/strtotime-doesnt-work-with-dd-mm-yyyy-format
$Navn = "test";
// stting to time
$Dato_op = $_POST['Dato_op'];
$Dato_op = str_replace('/', '-', $Dato_op);
$Dato_op = date('Y-m-d', strtotime($Dato_op));
$sql ="UPDATE tbl_test SET Navn='$Navn', Dato_op='$Dato_op' WHERE id=1";
$rs = mysqli_query($conn, $sql) or die ( mysqli_error($conn));
// studer denne slut
/*
MySql API
mysql_query($sql); // default connection
mysql_query($sql, $conn); // named connection
MySqlI API
mysql_query($conn,$sql); // procedural style
$conn->query($sql); // OOP style
*/
}
?>
<form action="test.php" method="post" enctype="multipart/form-data">
<input type="text" size="10" value="<?php echo date("d/m/Y"); ?>" name="Dato_op" class="bottom">
<!--
<input type="hidden" size="10" value="<?php echo date("d/m/Y"); ?>" name="Dato_op1" class="bottom">
-->
<input type="submit" value="Send" name="send"></td>
</form>
</body>
</html>