user5857398 user5857398 - 7 months ago 28
SQL Question

My database stays empty :(

The connection to the database works, but somehow the script doesn't write something in there. No Error-Message appears and the script also redirect me (in the last row) to danke.php.

Please take a look at this:

// validation
$valid = true;
if(
empty ( $vorname ) ||
empty ( $name ) ||
empty ( $strasse ) ||
empty ( $hausnr ) ||
empty ( $plz ) ||
empty ( $ort ) ||
empty ( $email )
){
$valid = false;
}

// database-connection
$db = mysqli_connect($db_server, $db_user, $db_password);
$db->select_db($db_name);

// send data
if($valid){
$sql = "
insert into 'bestellungen'
(
vorname, name, strasse, hausnr, plz, ort, email, bestelldatum
)
values
(
'". $vorname ."', '". $name ."', '". $strasse ."', '". $hausnr ."', '". $plz ."', '". $ort ."', '". $email ."', '". date('Y-m-d H:i:s') ."'
)
";
$db->query($sql);
header('location: danke.php');
}


If you need more code, please tell me. Im totally frustrated :(

Answer

Here,

 insert into 'bestellungen'

just remove the quotes around the table name:

 insert into bestellungen
Comments