<?php
$servername = "sn";
$username = "us";
$password = "pw";
$dbname = "db";
$name = $_POST['name'];
$adjective = $_POST['adjective'];
$noun = $_POST['noun'];
$verb = $_POST['verb'];
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
die("Connection failed: " . $conn->connect_error));
}
echo "Connected successfully";
// prepare and bind
$stmt = $conn->prepare("INSERT INTO mad (name, adjective, verb, noun) VALUES (?, ?, ?, ?)";
$stmt->bind_param("ssss", $name, $adjective, $verb, $noun);
$stmt->execute();
$stmt->close();
$conn->close();
When I try to run the prepared stmt part to make sure I can get the data inserted in the table from the form, I get an error. If i take everything out at the prepared statment, it connects successfully. The error I get is This page isn’t working HTTP ERROR 500