Hallo leute!!
Habe ein kleinen fehler, hab schon gegoogle und keine lösung gefunden.
fehler: 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 'WHERE ID = '3'' at line 3
code:
PHP
<?
// call to database
include("../cms_config/conf.php");
include("../cms_config/connect.php");
?>
<html>
<head>
<title>Unbenanntes Dokument</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="admin.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
a.link1 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 11px;
text-decoration: none;
color: #FFFFFF;
}
a.link1:hover {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 11px;
text-decoration: underline;
color: #009CFF;
}
-->
</style>
</head>
<body bgcolor="#666666" text="#000000" link="#000000" vlink="#000000" alink="#000000" class="text">
<p class="link1">
<?
if (isset($_REQUEST['id']))
{
if ($_POST['Send'])
{
//if formular is checked, update values
foreach($_POST as $key=>$wert)
{
//echo $key. ": " . $wert . "<br>";
${$key} = $wert;
if ($key=="Bild")
{
foreach($Bild as $wert)
{
$SQL3 = "DELETE FROM bilder WHERE ID = '".$wert."'";
mysql_query($SQL3, $DB);
if (mysql_affected_rows($DB) == 1) echo "<br> Ihr Bild wurde gelöscht!<br>";
}
}
}
// check for pictures
if (count($_FILES) > 0)
{
foreach($_FILES as $key=>$wert)
{
if ($wert['error']==0)
{
$Datei= $wert['tmp_name'];
$Name = $wert['name'];
$Type = $wert['type'];
$Size = $wert['size'];
$Mass = getimagesize($wert['tmp_name']);
$Height = $Mass[1];
$Width = $Mass[0];
$File = addslashes(fread(fopen($Datei, "rb"), filesize($Datei)));
$SQL = "INSERT INTO bilder (ID, Name, Auto, File, Typ, Local)
VALUES (NULL, '$Name', '".$_REQUEST['id']."', '$File', '$Type','Car')";
mysql_query($SQL, $DB);
if (mysql_affected_rows($DB) == 1) echo "Bild erfolgreich eingefügt!<br><br>";
else echo mysql_error($DB);
}
}
}
$Baujahr .= "/".$monat;
$SQL = "UPDATE news SET Titel = '$Titel',
Text = '$Text',
WHERE ID = '". $_REQUEST['id'] . "'" ;
mysql_query($SQL, $DB);
if (mysql_affected_rows($DB)==1)
{
echo "Änderungen erfolgreich übernommen!";
}
else
{
echo mysql_error($DB);
}
}
else
{
// chosen ID -> show saved settings
$SQL = "SELECT * FROM news WHERE ID = '".$_REQUEST['id']."'";
$RP = mysql_query($SQL, $DB);
$Result = mysql_fetch_object($RP);
?>
</p>
<form name="form1" method="post" enctype="multipart/form-data" action="<? echo $_SERVER['REQUEST_URI'] ; ?>">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" class="text">Titel</td>
<td ><input name="Titel" type="text" class="feld" value="<? echo $Result->Titel; ?>" size="60" maxlength="30"></td>
</tr>
<tr>
<td valign="top" class="text">Sonstiges:</td>
<td><textarea name="Text" cols="60" rows="20" class="feld" id="Text"><? echo $Result->Text; ?></textarea></td>
</tr>
<tr>
<td valign="top" class="text"> </td>
<td> </td>
</tr>
<tr>
<td valign="top" class="text">Bilder</td>
</tr>
<?
$SQL2 = "SELECT ID FROM bilder WHERE Auto = '".$Result->ID."'";
$RP = mysql_query($SQL2);
for($i=0; $i<mysql_num_rows($RP); $i++)
{
$ResCar = mysql_fetch_object($RP);
$BildAuto[$i] = $ResCar->ID;
}
for($a=0; $a<4; $a++)
{
echo '<tr>';
if (isset($BildAuto[$a]))
{ //if car-number a exists, load it
echo '<td><img name="car" src="scalbild.php?ID='.$BildAuto[$a] .'&x=100" alt=""><input name="Bild[]" type="checkbox" value="'.$BildAuto[$a].'">löschen</td>';
}
else
{ //do standard
echo '<td><input type="file" name="pic'.$a.'"></td>';
}
echo '</tr>';
}
?>
<td height="22"> </td>
<td><input name="Send" type="submit" class="feld" value="Abschicken"> <input name="Submit2" type="reset" class="feld" value="Zurücksetzen"></td>
</tr>
</table>
</form>
<?
}
}
else
{
// Show all Cars to choose ID
$SQL = "SELECT * FROM news";
$RP = mysql_query($SQL, $DB);
for ($i = 0; $i<mysql_num_rows($RP); $i++)
{
$Result = mysql_fetch_object($RP);
echo "<a class = \"text\"href = \"".$_SERVER['REQUEST_URI']."&id=".$Result->ID."\">".$Result->Titel." ".$Result->Typ." </a><br>";
}
}
?>
</body>
</html>
Alles anzeigen
fg
flo