I have a html website with a formular with an action to a php script. What I want to do is to write the data from the formular in a mySQL database on my localhost.
I know the database is accessable and the data is provided to the php script correctly (I'm using MAMP server for database and files). The prepare-statement is correct as far as I could figure it out. The 'id' in the execute statement is an auto-increment, therefore I set it to NULL.
$link is the db-access from db_connection.php
<?php
include("db_connection.php");
?>
<html>
<header>
<meta charset="utf-8">
<title>Stackoverflow Code</title>
</header>
<body>
<?php
$name = $_POST['name'];
$timeUnits = $_POST['timeUnits'];
$description = $_POST['description'];
$eintrag = $link->prepare("INSERT INTO `projekt`(`id`,`time-units`, `beschreibung`, `name`) VALUES (?,?,?,?)");
echo "It's working fine till this line";
$eintrag->execute([NULL, $timeUnits, $description, $name]);
?>
</body>
</html>
I expected it to write data in the database but what I get is an internal server error (ERROR 500) that instantly vanished from the browser console and a blank website.