Ik ben voor mijn sigchat bezig met een admin systeem... Nu heb ik al een goed werkende, edit en verwijder functie... Nu ben ik bezig met een soort van strafpunten systeem... Ik weet niet precies wat ik verkeerd gedaan heb maar ik krijg steeds deze error
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1' WHERE id = '190'' at line 1
Als ik eenmaal op addstrafid of minstrafid heb gedrukt...
Kan iemand me helpen om dit op te lossen???
http://www.wouser.phpvolution.com/beide/login.php
Als jezelf eens wilt kijken wat ie precies doet kun je daar naar toe gaan en inloggen onder, Wouser - test.
Database
CREATE TABLE `berichten` (
`id` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`naam` VARCHAR( 15 ) NOT NULL ,
`bericht` VARCHAR( 44 ) NOT NULL ,
`ip` VARCHAR( 30 ) NOT NULL ,
`straf` VARCHAR( 11 ) NOT NULL
) TYPE = MYISAM ;
De code:
<?php
include("config.php");
include("config2.php");
include("session.php");
include("navigatie.php");
?>
<html>
<head>
<title>Signchat - Admin</title>
</head>
<body>
<?php
if(isset($_SESSION['suser'])) {
// Bericht edit formulier
if (isset($editid)) {
$sql = "SELECT * FROM ".$tabel." WHERE id='$editid'";
$resultaat = mysql_query($sql) or die(mysql_error());
$rij = mysql_fetch_object($resultaat);
$naam = htmlspecialchars($rij->naam);
$bericht = nl2br(stripslashes(htmlspecialchars($rij->bericht)));
$ip = $rij->ip;
?>
<form method="post" action="<? echo "$PHP_SELF"; ?>"><input type="hidden" name="editid" value="<? echo "$editid"; ?>">
<table border="0" width="600">
<tr>
<td class="tabel">Teletet Naam:</td>
<td><input type="text" name="naam" size="50" value="<? echo $naam; ?>"></td>
</tr>
<tr>
<td class="tabel">Bericht:</td>
<td><input type="text" name="bericht" size="50" value="<? echo $bericht; ?>"></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="submit" value="Bericht wijzigen"></td>
</tr>
</table>
</form>
<?php
}
// Bericht deleten
if (isset($deleteid)) {
mysql_query ("DELETE FROM ".$tabel." WHERE id='$deleteid'");
include("maaksig.php");
}
// Bericht editen
if ($_POST['submit']) {
mysql_query("UPDATE ".$tabel." SET naam='".$_POST['naam']."',bericht='".$_POST['bericht']."' WHERE id = '".$editid."'") or die(mysql_error());
include("maaksig.php");
echo "<script>location.href='$PHP_SELF'</script>";
}
// Strafpunt toevoegen
if (isset($addstrafid)) {
$strafpunt = "1";
mysql_query("UPDATE ".$tabel." SET straf='".$straf + $strafpunt."' WHERE id = '".$addstrafid."'") or die(mysql_error());
include("maaksig.php");
}
// Strafpunt verminderen
if (isset($minstrafid)) {
$strafpunt = "1";
mysql_query("UPDATE ".$tabel." SET straf='".$straf - $strafpunt."' WHERE id = '".$minstrafid."'") or die(mysql_error());
include("maaksig.php");
}
// Functie navigatie, tabel + aantal berichten per pagina
navigatie($tabel, 40);
//navigatietonen();
// Alle berichten weergeven
$resultaat = mysql_query("SELECT * FROM ".$tabel." ORDER BY id DESC LIMIT ".$offset.", ".$aantal_items_per_pagina."") or die("Fout tijdens selecteren query: <br />". mysql_error());
echo "<TABLE BORDER=\"1\" WIDTH=\"900\" HEIGHT=\"10\">
<TR>
<TD WIDTH=\"12%\" ALIGN=\"justify\">Naam</TD>
<TD WIDTH=\"45%\" ALIGN=\"justify\">Bericht</TD>
<TD WIDTH=\"8%\" ALIGN=\"justify\">Edit</TD>
<TD WIDTH=\"8%\" ALIGN=\"justify\">Delete</TD>
<TD WIDTH=\"17%\" ALIGN=\"justify\">IP-Adres</TD>
<TD WIDTH=\"10%\" ALIGN=\"justify\">Strafpunten</TD>
</TR>
</TABLE>";
while ($rij = mysql_fetch_object($resultaat)){
$naam = htmlspecialchars($rij->naam);
$bericht = htmlspecialchars($rij->bericht);
$ip = $rij->ip;
$straf = $rij->straf;
echo "<TABLE BORDER=\"1\" WIDTH=\"900\" HEIGHT=\"10\">
<TR>
<TD WIDTH=\"12%\" ALIGN=\"justify\">".$naam."</TD>
<TD WIDTH=\"45%\" ALIGN=\"justify\">".$bericht."</TD>
<TD WIDTH=\"8%\" ALIGN=\"justify\"><a href=$PHP_SELF?editid=".$rij->id."><IMG SRC=\"img/edit.gif\" border=\"0\"></a></TD>
<TD WIDTH=\"8%\" ALIGN=\"justify\"><a href=$PHP_SELF?deleteid=".$rij->id."><IMG SRC=\"img/del.gif\" border=\"0\"></a></TD>
<TD WIDTH=\"17%\" ALIGN=\"justify\">".$ip."</TD>
<TD WIDTH=\"10%\" ALIGN=\"justify\">".$straf." <a href=$PHP_SELF?addstrafid=".$rij->id."><IMG SRC=\"img/add.gif\" border=\"0\"></a> <a href=$PHP_SELF?minstrafid=".$rij->id."><IMG SRC=\"img/min.gif\" border=\"0\"></a></TD>
</TR>
</TABLE>";
}
// Tonen navigatie
navigatietonen();
}
else
{
echo "Je bent niet ingelogd.<br>
Klik <a href=\"login.php\">hier</a> om in te loggen.";
}
?>
<TD align="justify""
</body>
</html>