Fehlermeldung: Duplicate entry '0' for key 1
Quellcode:
Datenbank:
CREATE TABLE `pic_comments` (
`id` int(4) NOT NULL default '0',
`Eintrag` text NOT NULL,
`UserName` text NOT NULL,
`Date` int(12) NOT NULL default '0',
`zu_ordner` varchar(30) NOT NULL default '',
`zu_bild` varchar(30) NOT NULL default '',
PRIMARY KEY (`id`)
) TYPE=MyISAM;
Quellcode:
PHP-Code:
echo "<br><br>Kommentar:<br><br>";
$count = 0;
$query_comm = "SELECT * FROM pic_comments WHERE zu_bild ='$file' and zu_ordner ='$ordner' ORDER by Date ASC";
$comm = mysql_query($query_comm)or die(mysql_error());
while ($row = mysql_fetch_array($comm))
{
echo "<!-- Kommentar".$row['id']." -->";
$count = $count+1;
$Date = $row['Date'];
$Datum = date("d.m.Y H:i",$Date);
echo "<table>";
echo "<tr>";
echo "<td>#$count Am $Datum";
echo "</td>";
echo "<td>Von: ".$row['UserName']."";
echo "</td>";
echo "</tr>";
echo "<tr>";
echo "<td colspan=\"2\">".$row['Eintrag']."";
echo "</td>";
echo "</tr>";
echo "</table>";
echo "<hr>";
}
echo "<br><br>";
echo "<form method=\"post\" action=\"\">";
echo "<textarea name=\"Kommentar\" cols=\"45\" rows=\"10\"></textarea><br>";
echo "<input type=\"submit\" value=\"Kommentienren\">";
echo "</form>";
echo "</center>";
echo "<br><a href=\"\" onClick=\"JavaScript:self.close()\">Dieses Fenster schließen</a><br><br>";
if(isset($Kommentar))
{
$Date = time();
$eintrag = "INSERT INTO pic_comments (Eintrag, UserName, Date, zu_ordner, zu_bild) VALUES ('$Kommentar', '$UserName', '$Date', '$ordner', '$file')";
$eintragen = mysql_query($eintrag)or die(mysql_error());
unset($kommentar);
echo "$eintragen";
echo "Erfolgreich eingetragen.";
}
CREATE TABLE `pic_comments` (
`id` int(4) NOT NULL default '0',
`Eintrag` text NOT NULL,
`UserName` text NOT NULL,
`Date` int(12) NOT NULL default '0',
`zu_ordner` varchar(30) NOT NULL default '',
`zu_bild` varchar(30) NOT NULL default '',
PRIMARY KEY (`id`)
) TYPE=MyISAM;
Kommentar