I am inserting data into a table using PHP and want to find out if the SQL has worked properly so I can display a success message. Is there a way of returning success from SQL back to PHP after the statement is executed.
function addPlayer($playerName, $dateOfBirth, $team) {
$sql = "INSERT INTO players VALUES (DEFAULT, :name, :teamID, :dob)";
$stmt = $this->connection->conn->prepare($sql);
$stmt->bindParam(":name", $playerName);
$stmt->bindParam(":dob", $dateOfBirth);
$stmt->bindParam(":teamID", $team);
$stmt->execute();
}
I want to know if the execute statement has been successful and the data added to the table. Is there a way to have the SQL return a success or fail so I can display an error or success message on the page?