Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save barmgeat/f445c49ec5d2fc31bf3a66248e085808 to your computer and use it in GitHub Desktop.
Save barmgeat/f445c49ec5d2fc31bf3a66248e085808 to your computer and use it in GitHub Desktop.
<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDB";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "UPDATE MyGuests SET lastname='Doe' WHERE id=2";
if ($conn->query($sql) === TRUE) {
echo "Record updated successfully";
} else {
echo "Error updating record: " . $conn->error;
}
$conn->close();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment