0
我在使用php進行ajax調用後執行了數據庫操作, 1)我看到fiddler中對PHP(ajax調用)的請求和響應沒有問題但2)我看到錯誤「拒絕訪問用戶root'@'localhost'(在提琴手中使用密碼:NO)無法使用PHP在Ajax調用中連接到MY SQL DB
我不是試圖連接到root,而是連接到不同的用戶 這裏是其中Ajax調用發起view.php文件:
$.ajax({
url: 'delete_entry.php',
data: "id="+del_id,
type: 'post',
success: function(output) {
alert("Success");
//document.getElementById("test1").innerHTML = output;
}
});
我收到警告信息「成功」,雖然
。守則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());
?>
請幫助,因爲我不明白爲什麼MySQL數據庫嘗試連接到root eventhough我指定的DB detais爲「TESTDB」。 我可以用我的view.php中的憑據連接到相同的數據庫
只是瘋狂的猜測:嘗試重新加載多次。瀏覽器可能會緩存。 – 1000111