Hallo,
also ich habe folgendes Problem. Ich will ein Datum aus einem Textfeld in einer Datenbank speichern lassen. allerdings ändert er mir immer das datum in ein anderes Format.
wenn ich jetzt als Datum den 01.08.2009 zum Beispiel eintrage, erhalte ich bei der Ausgabe den 20.08.2001. Wenn ich über phpmyadmin nachschaue, dann wird das Datum schon falsch in die Tabelle eingetragen. Was mache ich denn falsch? Die Ausgabe an sich ist ja kein Problem. Die sieht folgendermaßen aus:
also ich habe folgendes Problem. Ich will ein Datum aus einem Textfeld in einer Datenbank speichern lassen. allerdings ändert er mir immer das datum in ein anderes Format.
PHP-Code:
<?php
include("dbconnect.php");
$sql="INSERT INTO Videos (datum, name, datei)
VALUES
('$_POST[datum]','$_POST[name]','$_POST[datei]')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "<b>$_POST[name]</b> eingetragen!";
mysql_close($con);
?>
PHP-Code:
<?php
include("intern/dbconnect.php");
$result = mysql_query("SELECT Name, Datei, DATE_FORMAT(Datum, '%d.%m.%Y') AS Datum FROM Videos ORDER BY Datum DESC");
echo "<table border='1'>
<tr>
<td><b>Datum</b></td>
<td><b>Video</b></td>
<td><b>Ansehen</b></td>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['Datum'] . "</td>";
echo "<td>" . $row['Name'] . "</td>";
echo "<td>" . $row['Datei'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysql_close($con);
?>

Kommentar