I'm Posting data using PHP into a mysqlserver. (Rest service) The problem is I'm getting this error:
Connection failed: Access denied for user 'root'@'localhost' (using password: YES).
I changed my query from an insert to a select statement and it works, i could retrieve the data but i cant seem to do an insert. I have checked privileges and even changed password. I'm Sure this question has been asked before but the solutions i have tried don't work problem could be unique to context. I'm not sure if its the code or what? Please help.
<?php
$servername = "localhost";
$username = "root";
$password = "****";
$dbname = "TripBuddy";
$name = $_POST['Name'];
$surname = $_POST['Surname'];
$email = $_POST['Email'];
$password = $_POST['Password'];
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "INSERT INTO 'TripBuddy'.'AppUser01' ('Name', 'Surname', 'Email', 'Password') VALUES ('$name','$surname','$email','$password');";
if ($conn->query($sql) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();
?>