I am currently following W3Schools tutorial with Prepared SQL statements, When I try to insert data into the database it's saying $firstname = "Nathan" and $lastname = "Kent" is an unused local variable? Also it returns no error so it's connecting fine and when I check the database it has no new entries.
function setData(){
global $servername;
global $username;
global $password;
global $dbname;
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
} else{
echo "Connection Successful" . "<br>";
}
$stmt = $conn->prepare("INSERT INTO test(firstname, surname) VALUES (?,?)");
$stmt->bind_param("ss", $firstname, $surname);
$firstname = "James";
$lastname = "Williams";
$stmt->execute();
echo "New Records Created";
$stmt->close();
$conn->close();
}