So, hier ist das HTML-Formular IMySQL-Abfrage nicht mit PHP arbeiten, aber Abfrage läuft auf phpMyAdmin SQL
<form action="upload.php" method="post" enctype="multipart/form-data">
<table border="2px">
<tr>
<td>Date</td>
<td>Day</td>
<td>Height</td>
<td>Weight</td>
<td>Biceps(Open)</td>
<td>Biceps(Curled)</td>
<td>Photo</td>
<td>Action</td>
</tr>
<tr>
<td><input type="date" name = "date"></td>
<td><select name="day">
<?php for ($x = 1; $x <= 100; $x++) { ?>
<option>
<?php echo $x;
} ?></option>
</select>
</td>
<td><select name="height">
<?php for ($x = 170; $x <= 180; $x++) { ?>
<option>
<?php echo $x;
} ?></option>
</select> Centimeters
</td>
<td><select name="weight">
<?php for ($x = 60; $x <= 80; $x++) { ?>
<option>
<?php echo $x;
} ?></option>
</select> Kilograms
</td>
<td><select name="biceps_o">
<?php for ($x = 10; $x <= 15; $x++) { ?>
<option>
<?php echo $x;
} ?></option>
</select> Inches
</td>
<td><select name="biceps_c">
<?php for ($x = 10; $x <= 15; $x++) { ?>
<option>
<?php echo $x;
} ?></option>
</select> Inches
</td>
Select image to upload:
<td><input type="file" name="fileToUpload" id="fileToUpload"></td>
<td><input type="submit" value="Add" name="submit"></td>
</tr>
</table>
</form>
bin mit und hier ist die upload.php Datei
<?php
$target_dir = "images/";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
$uploadOk = 1;
$imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
// Check if image file is a actual image or fake image
if(isset($_POST["submit"])) {
$check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
if($check !== false) {
echo "File is an image - " . $check["mime"] . ".";
$uploadOk = 1;
} else {
echo "File is not an image.";
$uploadOk = 0;
}
}
// Check if file already exists
if (file_exists($target_file)) {
echo "Sorry, file already exists.";
$uploadOk = 0;
}
// Check file size
if ($_FILES["fileToUpload"]["size"] > 500000) {
echo "Sorry, your file is too large.";
$uploadOk = 0;
}
// Allow certain file formats
if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg"
&& $imageFileType != "gif") {
echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed.";
$uploadOk = 0;
}
// Check if $uploadOk is set to 0 by an error
if ($uploadOk == 0) {
echo "Sorry, your file was not uploaded.";
// if everything is ok, try to upload file
} else {
if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
echo "The file ". basename($_FILES["fileToUpload"]["name"]). " has been uploaded.";
} else {
echo "Sorry, there was an error uploading your file.";
}
}
$date = $_POST['date'];
$day = $_POST['day'];
$height = $_POST['height'];
$weight = $_POST['weight'];
$biceps_o = $_POST['biceps_o'];
$biceps_c = $_POST['biceps_c'];
echo $sql_query = "INSERT INTO gym (date, day, height, weight, biceps_o, biceps_c, image) VALUES('$date', '$day', '$height', '$weight', '$biceps_o', '$biceps_c', '$target_file')";
if($sql_result = mysql_query($sql_query))
echo "Data Successfully Added!";
else
echo "Data Entry Failed!";
?>
aber wenn i führen sie den Code und laden meine Daten, die es gibt die folgende
Datei ein Bild ist - Bild/jpeg.The aid62387-728px-Cross-Your-Eye-Datei s-Step-2.jpg wurde hochgeladen.INSERT IN Gym (Datum, Tag, Größe, Gewicht, Bizeps_o, Bizeps_c, Bild) WERTE ('2016-08-15', '1', '170', ' 60 ',' 10 ',' 10 ', ' Bilder/aid62387-728px-Cross-Your-Eyes-Schritt-2.jpg ') Dateneingabe fehlgeschlagen!
Nun, das Bild ist perfekt hochgeladen, aber die Abfrage läuft nicht richtig. aber die gleiche Abfrage
INSERT INTO Turnhalle (Datum, Tag, Größe, Gewicht, biceps_o, biceps_c, Bild) VALUES ('2016.08.15', '1', '170', '60 ‘, '10', '10', 'images/aid62387-728px-Cross-Your-Eyes-Step-2.jpg')
funktioniert völlig in Ordnung, wenn ich es in phpMyAdmin sQL laufen. Was könnte das Problem sein?
Verwendung mysql_error um herauszufinden, was geschehen ist – Jens
** Stopp ** mit deprected 'mysql_ *' API. Verwenden Sie 'mysqli_ *' oder 'PDO' mit vorbereiteten Anweisungen, um SQL-Injektion zu verhindern – Jens
wo ist Ihre MySQL-Verbindung? – Rijin