Last active
December 27, 2020 21:07
-
-
Save barmgeat/6e2e318bd5ba7ada982339e7f385caf7 to your computer and use it in GitHub Desktop.
add new data to the MySQL Table .
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//insert new data to the table myGuests : | |
$sql = "INSERT INTO MyGuests (firstname, lastname, email) | |
VALUES ('John', 'Doe', '[email protected]')"; | |
//check if the statement successfully applicated : | |
if ($conn->query($sql) === TRUE) { | |
$last_id = $conn->insert_id; | |
echo "New record created successfully. Last inserted ID is: " . $last_id; | |
} else { | |
echo "Error: " . $sql . "<br>" . $conn->error; | |
} | |
//close the connection to the database : | |
$conn->close(); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment