0

I dont really know why the code is not really working. I think it have something to do with the INSERT INTO but I dont know.

<?php
$verbindung = mysql_connect("localhost", "root", "") or die ("Fehler :D Verbindung zum Mysql");
mysql_select_db("onlineshop") or die ("Fehler Verbindung mit Datenbank");
$vorname = $_POST['vorname'];
$name = $_POST['name'];
$strasse = $_POST['strasse'];
$nummer = $_POST['nummer'];
$plz = $_POST['plz'];
$ort = $_POST['ort'];
$telefon = $_POST['telefon'];
$iban = $_POST['iban'];
$land = $_POST['land'];
if($vorname == ""){
echo "Du hast die Felder nicht ausgefüllt...";} 
else {

$eintrag = "INSERT INTO Kunde (Kunde ID, name, Vorname, Straße, Straße Nr., Telefon, IBAN, PLZ, ort, land, Anmeldedatum) 
            VALUES ('null' ,'$name', '$vorname', '$strasse', '$nummer', '$telefon', '$iban', '$plz', '$ort', '$land', 'null')";

$eintragen = mysql_query($eintrag);

if($eintragen == true){
    echo "Eintrag war Erfolgreich";
}
else {
    echo "ERROR " . $eintrag .;} } mysql_close($verbindung); ?>"
  • Do you get an error? What PHP version are you using? mysql_query has been removed in PHP 7. – Don't Panic May 17 '17 at 15:18
  • 4
    Don't use the `mysql_*` functions. They have been deprecated since v5.5 (Jun 2013) and removed since v7.0 (Dec 2015). Instead use the [**mysqli_***](https://secure.php.net/manual/en/book.mysqli.php) or [**PDO**](https://secure.php.net/manual/en/book.pdo.php) functions with [**prepared statements**](https://secure.php.net/manual/en/pdo.prepare.php) and [**bound parameters**](https://secure.php.net/manual/en/pdostatement.bindparam.php). – Alex Howansky May 17 '17 at 15:18
  • in the query -> `name` is part of the [MySQL reserved/keywords](https://dev.mysql.com/doc/refman/5.7/en/keywords.html) – OldPadawan May 17 '17 at 15:20
  • @OldPadawan name is not reserved, so it should be able to be used without quoting. – Don't Panic May 17 '17 at 15:21
  • 1
    The column names with spaces and dots, on the other hand... – Don't Panic May 17 '17 at 15:22
  • oh ok I will try thx for the reply – Rui Liu May 17 '17 at 15:26
  • @Don'tPanic : you're right, misread/understood the meaning in the doc when I checked :/ (just done that again) – OldPadawan May 17 '17 at 15:29
  • This question contains too many errors. Consult all the (additional) duplicates (added). – Funk Forty Niner May 17 '17 at 15:30

0 Answers0