Hallo,
ich erhalte die folgende Fehlermeldung in einem Skript und finde den Fehler einfach nicht.
Eventuell bin ich inzwischen Betriebsblind und möchte daher die Frage in die Runde stellen.
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 '43', Serie='42', Type='15', PrepTime='2003', Calories='78:22', Serves='1', hoere' at line 1
Hier der Relevante Teil für Hinzufügen Funktion und INSERT Befehl
Wenn jemand den Fehler sieht würde ich mich über eine Info freuen.
ich erhalte die folgende Fehlermeldung in einem Skript und finde den Fehler einfach nicht.
Eventuell bin ich inzwischen Betriebsblind und möchte daher die Frage in die Runde stellen.
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 '43', Serie='42', Type='15', PrepTime='2003', Calories='78:22', Serves='1', hoere' at line 1
Hier der Relevante Teil für Hinzufügen Funktion und INSERT Befehl
PHP:
function newForm($width,$rid=0){
GLOBAL $cfg,$_SERVER,$_GET,$_POST,$_SESSION,$_SERVER;
if($_SESSION['auth']['status'] != 1){return "";}
if(($_POST['do'] == "insert")||($_POST['do'] == "update")){
$hilight = " background:".$cfg['color_11']."; border:1px solid ".$cfg['color_1'].";";
$ok = true;
// TEST IF TITLE IS BLANK
if(empty($_POST['TITLE'])){
$ok = false;
$message[] = "Du musst einen Namen eingeben.";
$hilightTitle = $hilight;
}
// TEST IF CATEGORY IS BLANK
if(empty($_POST['CATEGORY'])){
$ok = false;
$message[] = "Du musst eine CATEGORY auswählen.";
$hilightCategory = $hilight;
}
if($ok == true){
if($_POST['do'] == "insert"){
if($cfg['useMailFeatures'] == "yes"){
$_POST['submittedBy'] = $_SESSION['auth']['ID'];
$rid = insert1($_POST);
if($rid >= 1){
sendmixesSubmittionEmail();
header("Location: ./details.php?rid=".$rid."&msg=10");
}
}else{
$_POST['submittedBy'] = $_SESSION['auth']['ID'];
$rid = insert1($_POST);
if($rid >= 1){
header("Location: ./details.php?rid=".$rid."&msg=10");
}
}
}elseif($_POST['do'] == "update"){
$rid = update1($_POST);
if($rid >= 1){
header("Location: ./details.php?rid=".$rid."&msg=20");
}
}
}
}else{$ok = false;}
if($ok == false){
if($width < 400){$width = 400;}
$selectWidth = 189;
$str[] = form(1,$_SERVER['PHP_SELF'],"new1");
if($rid >= 1){
$query = @mysql_query("SELECT * FROM ".$cfg['TABLE']." WHERE ID='".$rid."'");
$data = @mysql_fetch_array($query);
$str[] = hidden("do","update");
$str[] = hidden("rid",$rid);
}else{
$data = $_POST;
$str[] = hidden("do","insert");
}
if(is_array($message)){
$str[] = attentionDialog($message);
$str[] = "<p>";
}
$str[] = "<div class='box_1' style='width:".$width."px;'>";
$str[] = "<div class='largeTitle' style='width:".$width."px; height:32px; border-bottom: 1px solid ".$cfg['color_2'].";'>Neuer Eintrag</div>";
$str[] = "<div style='padding:20px; text-align:center;'>";
$str[] = table(1,0,0,0,0," style='padding:3px;'");
$str[] = tr();
$str[] = td(1,"basicText",0,0,0,0,0," style='padding-left:5px;".$hilightTitle."'")."<B>Titel</B>".td(2);
$str[] = td(1,"basicText",0,0,0,0,0," style='padding-left:5px;".$hilightTitle."'")."<input type=text name='TITLE' value=\"".stripslashes($data['TITLE'])."\" style='width:240px;'>".td(2);
$str[] = tr(2);
$str[] = tr();
$str[] = td(1,"basicText",0,0,0,0,0," style='padding-left:5px;".$hilightCategory."'")."<B>CATEGORY:</B>".td(2);
$str[] = td(1,"basicText",0,0,0,0,0," style='padding-left:5px;".$hilightCategory."'").categorySelect($selectWidth,$data['CATEGORY']).td(2);
$str[] = tr(2);
$str[] = tr();
$str[] = td(1,"basicText",0,"Top",0,0,0," style='padding-left:5px;'")."<B>Image:</B>".td(2);
$str[] = td(1,"basicText",0,0,0,0,0," style='padding-left:5px;'")."<input type=file name='Image' id='Image' value=\"".stripslashes($data['Image'])."\" style='width:300px; font:normal 9pt solid;'><input type=button value='Remove' onClick=\"doClear(Image);\" style='font: normal 8pt Arial;'><div class='basicSmallText' style=''>(Hier können Sie ein Bild hochladen)</div>".td(2);
$str[] = tr(2);
if(is_file("./images/".$data['Image'])){
$str[] = "<img src='".$cfg['webaddress']."/images/".$data['Image']."' border=0 style='width:100px;'>";
$str[] = "<br>";
}else{
$str[] = "";
$str[] = "<br>";
}
$str[] = table(2);
$descKeyDown = " onKeyDown=\"textCounter(document.new1.description,document.new1.remLen2,255)\"";
$descKeyUp = " onKeyUp=\"textCounter(document.new1.description,document.new1.remLen2,255)\"";
$str[] = "<p><div class='basicText' style=' padding-bottom:15px; padding-top:10px; text-align:left;'><b>Kurzbeschreibung:</b><br>";
$str[] = "<div class='basicText'><textarea name='description' style='width:100%; height:75px;'".$descKeyDown.$descKeyUp.">".stripslashes(nl2br($data['description']))."</textarea></div>";
$str[] = "<div class='basicText' style='background:".$cfg['color_1']."; border: 1px solid ".$cfg['color_2'].";'><input readonly type='text' name='remLen2' size='3' maxlength='3' value='255' style='font: normal 8pt Arial;'> Zeichen verfügbar</div>";
$str[] = "</div>";
$str[] = "<div class='titleRow' style='text-align:left; width:100%; border: 1px solid ".$cfg['color_2'].";'>Zutatenliste: <small>(Nach speichern erfolgt automatisch die Nummerierung)</small></div>";
$str[] = "<div class='basicText' style='width:100%;'><textarea name='IngredientDetails' style='width:100%; height:400px;'>".stripslashes($data['IngredientDetails'])."</textarea></div>";
$str[] = "<div class='basicSmallText' style='width:100%; text-align:center; background:".$cfg['color_1']."; border: 1px solid ".$cfg['color_2'].";'>(In dieses Feld sollte ausschließlich die Zutatenliste geschrieben werden)</div>";
$str[] = "<p><div class='titleRow' style='text-align:left; width:100%; border: 1px solid ".$cfg['color_2'].";'>Informationen:</div>";
$str[] = "<div class='basicText' style='width:100%;'><textarea name='PreparationDetails' style='width:100%; height:400px;'>".stripslashes($data['PreparationDetails'])."</textarea></div>";
$str[] = "<div class='basicSmallText' style='width:100%; text-align:center; background:".$cfg['color_1']."; border: 1px solid ".$cfg['color_2'].";'>(Geben Sie hier Ihre Informationen an)</div>";
}
$str[] = "<div class='basicText' style='padding-top: 15px; text-align:center;'><input type=submit value='Submit' style='font: normal 8pt Arial;'></div>";
$str[] = "<div class='basicSmallText' style='padding-top: 15px; text-align:center;'>Wird nach Freigabe für alle sichtbar. <br>Den Status kannst Du unter 'Meine Rezepte' sehen.'</div>";
$str[] = "</div>";
$str[] = form(2);
return implode("\n",$str);
}
}
function uploadImage($rid){
GLOBAL $cfg,$_FILES;
if(!empty($_FILES['Image']['tmp_name'])){
$maxSize = $cfg['imageMaxSize'];
$ext = strtolower(pathinfo($_FILES['Image']['name'],PATHINFO_EXTENSION));
$uploadFileName = "img_".$rid.".".$ext;
if(($ext == "jpg")||($ext == "jpeg")||($ext == "gif")||($ext == "png")){
list($width,$height) = getimagesize($_FILES['Image']['tmp_name']);
$newwidth = $maxSize;
$newheight = ($height/$width)*$maxSize;
if(($width <= $newwidth)||($height <= $newheight)){
move_uploaded_file($_FILES['Image']['tmp_name'], "./images/".$uploadFileName);
}else{
if(($ext == "jpg")||($ext == "jpeg")){
$src = imagecreatefromjpeg($_FILES['Image']['tmp_name']);
$tmp = imagecreatetruecolor($newwidth,$newheight);
imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
imagejpeg($tmp,"./images/".$uploadFileName,75);
imagedestroy($src); imagedestroy($tmp);
}elseif($ext == "gif"){
$src = imagecreatefromgif($_FILES['Image']['tmp_name']);
$tmp = imagecreatetruecolor($newwidth,$newheight);
imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
imagegif($tmp,"./images/".$uploadFileName,75);
imagedestroy($src); imagedestroy($tmp);
}elseif($ext == "png"){
$src = imagecreatefrompng($_FILES['Image']['tmp_name']);
$tmp = imagecreatetruecolor($newwidth,$newheight);
imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
imagepng($tmp,"./images/".$uploadFileName,75);
imagedestroy($src); imagedestroy($tmp);
}
}
chmod("./images/".$uploadFileName,0644);
@mysql_query("UPDATE ".$cfg['TABLE']." SET Image='".$uploadFileName."' WHERE ID='".$rid."'")or die(@mysql_error());
}else{
$msg[] = "Nur folgende Dateien sind erlaubt: <B>jpg</B>, <B>jpeg</B>, <B>gif</B>, or <B>png</B>";
echo attentionDialog($msg)."<p>";
}
}
}
function insert1($values,$approved='pending'){
GLOBAL $cfg,$_FILES,$_SESSION;
if(is_array($values)){
unset($values['do'],$values['remLen2']);
$values['timestamp'] = mktime();
$values['approved'] = $approved;
while(list($key,$val)=each($values)){
if($key == "ingredients"){$val = createIngredientsStr($val);}
$sqlArr[] = $key."='".$val."'";
}
if(is_array($sqlArr)){
$sqlStr = implode(", ",$sqlArr);
$sqlStr = stripslashes(str_replace(array('’','–','—',' presents ',' Presents ',' Pres ',' Pres. ',' AND ',' and ',' And ', ' From ',' FROM '),array('´','-','-',' pres. ',' pres. ',' pres. ',' pres. ',' & ',' & ',' & ',' from ',' from '),$sqlStr));
$saveQ = @mysql_query("INSERT INTO ".$cfg['TABLE']." SET ".$sqlStr)or die(@mysql_error());
$rid = @mysql_insert_id();
uploadImage($rid);
return $rid;
}else{return false;}
}else{return false;}
}
function update1($values){
GLOBAL $cfg,$_FILES;
if(is_array($values)){
$rid = $values['rid'];
unset($values['do'],$values['rid'],$values['remLen2']);
while(list($key,$val)=each($values)){
if($key == "ingredients"){$val = createIngredientsStr($val);}
$sqlArr[] = $key."='".$val."'";
}
if(is_array($sqlArr)){
$sqlStr = implode(", ",$sqlArr);
$sqlStr = stripslashes(str_replace(array('’','–','—',' presents ',' Presents ',' Pres ',' Pres. ',' AND ',' and ',' And ', ' From ',' FROM '),array('´','-','-',' pres. ',' pres. ',' pres. ',' pres. ',' & ',' & ',' & ',' from ',' from '),$sqlStr));
$saveQ = @mysql_query("UPDATE ".$cfg['TABLE']." SET ".$sqlStr." WHERE ID='".$rid."'")or die(@mysql_error());
uploadImage($rid);
return $rid;
}else{return false;}
}else{return false;}
Wenn jemand den Fehler sieht würde ich mich über eine Info freuen.