MySQL Forums
Forum List  »  PHP

Re: Updating mysql from php
Posted by: misha rajpoot
Date: March 14, 2019 12:32AM

,?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();
?>

I hope it works for you

Options: ReplyQuote


Subject
Written By
Posted
T R
February 22, 2019 03:55PM
February 23, 2019 09:30AM
Re: Updating mysql from php
March 14, 2019 12:32AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.