My problem is that upon loading this code the problem in the title ocours. What is causing this problem? I have spent a lot of time trying to solve it now and i am going nuts. I'm trying to do a simple insertion of input data into my database named 'kurv'. My connection to the database seems to be set up fine.
<form method='POST' action=''>
Firstname:<input type='text' name='fornavn'><br>
Lastname:<input type='text' name='efternavn'><br>
<button>Insert</button>
</form>
<?php
$fornavn = $_POST['fornavn'];
$efternavn = $_POST['efternavn'];
$sql = "INSERT INTO kurv (fornavn, efternavn)
VALUES('$fornavn', '$efternavn')";
if ($conn->query($sql) === TRUE) {
echo 'New record created successfully';
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();
?>
The error in the title is raised on line 12 (First echo in if statement).
Please help