MYSQL/PHP - Kein Eintrag in die DB möglich
Basti
- php
Hallo! Ich habe seit längerem kein PHP mehr gemacht, möchte aber nun meine etwas verstaubten Seiten wieder auffrischen. Nun habe ich aber folgendes Problem - an dem ich jetzt schon den ganzen Tag verzweifelt sitze: Ich habe folgendes Upload-Skript, mit denen Bilder hochgeladen werden können. An diesen werden dann vers. Veränderungen vorgenommen .. Das ist aber nicht mein Problem. Mein Problem besteht darin, dass sich meine Daten nicht mehr in die DB eintragen. Könnt ihr mir sagen, woran es leigt? Hier der Code (die möglicherweise irrelevanten Sachen hab ich schonmal rausgenommen):
mysql_connect($hostname,$dbuser,$dbpass) OR DIE( "Couldn't connect to MySQL server!"); mysql_select_db($dbname) or DIE( "Keine Datenbank erreichbar!" );
if ($aktion<>"upload") { // NORMAL
// FORMULAR ANZEIGEN ?> <h1>Bilder-Upload</h1> <table border=0> <tr><td><form name="form1" method="post" action="?aktion=upload" enctype="multipart/form-data"></td></tr> <tr><td>Bild :</td><td><input type="file" name="file1"></td></tr> <tr><td valign=top>Beschreibung :</td><td><textarea name="beschreibung" cols=40 rows=6></textarea></td></tr>
<tr><td>Veranstaltung :</td><td><input type="text" name="veranstaltung"></td></tr>
<tr><td>Ort :</td><td><input type="text" name="ort"></td></tr>
<tr><td>Ressort :</td><td><select name="ressort" size=1><option>Wähle ein Ressort <option>Leichtathletik <option>Fußball <option>Handball <option>Politik </select> anderes Ressort : <input type="text" name="r2"></td></tr> </tr>
<tr><td>Datum :</td><td><input type="text" name="datum"></td></tr>
<tr><td></td><td><input type="submit" name="Abschicken" value="Abschicken"> <input type="reset" name="Löschen"></form></td></tr> </table>
<?
} else { // UPLOAD if (($_POST['beschreibung']<>'') && ($_POST['veranstaltung']<>'') && ($_POST['ort']<>'') && ($_POST['datum']<>'') && ($_POST['ressort']<>'')) { srand ((double)microtime() * 1000000); $randval = rand(1,10000); //} if (empty($file1_name)) { echo "<b>Keine Datei angegeben, daher Standardbild eingefügt!</b><br>"; $bild1=addslashes(realpath("upload/standard.jpg"));
} else {
if(copy($file1,"".basename($file1_name))){ $bild1=addslashes(("".$file1_name));} if(copy($file1,"original/".basename($file1_name))){ $original=addslashes(("".$file1_name));
}
if(!empty($file1)){ if(copy($file1_name,"$file1")){ if(move_uploaded_file($file,"$file")){ echo "<b>Upload beendet!</b><br>"; } } }
list($width, $height) = getimagesize($bild1); $new_height = ($height/2)-3; $new_width = ($width/2)-60; $fgroesse = filesize($bild1); $im = ImageCreateFromJPEG($bild1); //$back_color = ImageColorAllocate($im,255, 255,255); $text_color = ImageColorAllocate($im,255, 255,255); $schwarz = ImageColorAllocate($im,0,0,0); ImageString($im, 5, $new_width, $new_height, "www.test.de", $schwarz); //ImageFilledRectangle($im, $new_width, $new_height, $new_width2, $new_height2, $text_color); Header("Content-type: image/jpeg"); ImageJPEG($im,$bild1); ImageDestroy($im);
//werte in array $bildsize $input = addslashes(("".$bild1)); // upload/ echo $input; $output = addslashes(("./upload/thumbs/".$bild1)); // upload $width_old= $bildbreite; $height_old= $bildhoehe; $width_new = $bildbreiteneu; $height_new= $bildhoeheneu; $bildsize=getimagesize($input); //auswertung array $bildbreite=$bildsize[0]; $bildhoehe=$bildsize[1]; ///CHECKING HORIZONTAL if($bildbreite>$bildhoehe) { $bildbreiteneu=250; $rat=(100/$bildbreite)$bildbreiteneu; $bildhoeheneu=intval($bildhoehe($rat/100)); }
///CHECKING VERTICAL if($bildhoehe>$bildbreite) { $bildhoeheneu=250; $rat=(100/$bildhoehe)$bildhoeheneu; $bildbreiteneu=intval($bildbreite($rat/100)); }
image_resize($input,$output,$bildbreite,$bildhoehe,$bildbreiteneu,$bildhoeheneu);
$bild2=$output; echo "<br><b>Upload beendet!</b><br>";
// Ab hier kommen neue Ergänzungen!!!
//werte in array $bildsize $input1 = addslashes(("".$bild1)); // upload/ echo $input1; $output1 = addslashes(("./upload/preview/".$bild1)); // upload $width_old1= $bildbreite1; $height_old1= $bildhoehe1; $width_new1 = $bildbreiteneu1; $height_new1= $bildhoeheneu1; $bildsize1=getimagesize($input1); //auswertung array $bildbreite1=$bildsize1[0]; $bildhoehe1=$bildsize1[1]; ///CHECKING HORIZONTAL if($bildbreite1>$bildhoehe1) { $bildbreiteneu1=600; $rat1=(100/$bildbreite1)$bildbreiteneu1; $bildhoeheneu1=intval($bildhoehe1($rat1/100)); }
///CHECKING VERTICAL if($bildhoehe1>$bildbreite1) { $bildhoeheneu1=600; $rat1=(100/$bildhoehe1)$bildhoeheneu1; $bildbreiteneu1=intval($bildbreite1($rat1/100)); }
image_resize($input1,$output1,$bildbreite1,$bildhoehe1,$bildbreiteneu1,$bildhoeheneu1);
$bild1=$output1; echo "<br><b>Upload beendet!</b><br>"; }
// Ende neue Ergänzungen if ($ressort == "Wähle ein Ressort!") {$r2; }
//$eintrag = "INSERT INTO bilder (id, name, bild, veranstaltung, beschreibung, ort, datum,ressort,r2,breite,hoehe,fgroesse) values ('$id','$name','$bild1','$veranstaltung','$beschreibung','$veranstaltungsort','$datum','$ressort','$r2','$width','$height','$fgroesse')"; $eintrag = "INSERT INTO bilder (id, bild, veranstaltung, beschreibung, ort, datum) values ('$id','$bild1','$veranstaltung','$beschreibung','$ort','$datum')"; $eintragen = mysql_query($eintrag);
echo mysql_error(); } else { echo "felder nicht alle ausgefüllt"; }
} function image_resize($input,$output,$width_old,$height_old,$width_new,$height_new) { echo $image_old; $image_old = ImageCreateFromJPEG($input); $image_new = ImageCreatetruecolor($width_new,$height_new); ImageCopyResampled($image_new,$image_old,0,0,0,0,$width_new,$height_new,$width_old,$height_old); ImageJPEG($image_new,$output,"75"); ImageDestroy($image_new); }
// Wieder neue Ergänzungen if ($image_new1 != ""){ function image_resize($input1,$output1,$width_old1,$height_old1,$width_new1,$height_new1) { echo $image_old1; $image_old1 = ImageCreateFromJPEG($input1); $image_new1 = ImageCreatetruecolor($width_new1,$height_new1); ImageCopyResampled($image_new1,$image_old1,0,0,0,0,$width_new1,$height_new1,$width_old1,$height_old1); ImageJPEG($image_new1,$output1,"75"); ImageDestroy($image_new1); }}
Hello,
nur so als Tipp:
streich den Code mal zusammen auf den wesentlichen Teil. Sonst glaub ich nicht, dass Dir jemand hilft. Außerdem findest Du den Fehler dann vielleicht auch schon alleine.
Harzliche Grüße aus http://www.annerschbarrich.de
Tom