I am performing a DB operation after making an ajax call using php, 1) I see in fiddler that the request and response to the PHP (ajax call) are fine but and 2) I see the error "Access denied for user 'root'@'localhost' (using password: NO" in Fiddler.
I am not trying to connect to root but to a different user. Here is the view.php file where ajax call is initiated:
$.ajax({
url: 'delete_entry.php',
data: "id="+del_id,
type: 'post',
success: function(output) {
alert("Success");
//document.getElementById("test1").innerHTML = output;
}
});
I recieve the alert message "Success" though.
Code in delete_entry.php:
<?php
$servername = "localhost";
$username = "testdb";
$password = "testdb";
$dbname = "testts";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
echo "Connection Failed";
die("Connection failed: " . $conn->connect_error);
}
$id=$_POST['id'];
echo $id; // I get a proper Id here
$delete = "DELETE FROM ExpenseTable WHERE Id='"+$id+"'";
$result = mysql_query($delete) or die(mysql_error());
?>
Please help as I do not understand why the mysql db is trying to connect to root eventhough I specify the db detais as "testdb". I am able to connect to the same db with these credentials in my view.php