我正在爲一家公司創建一個非常小的簡單CRM,它們要求該功能能夠通過儀表板查看最近的25個訂單。訂單通過CRM中的訂單添加表單添加。 當添加如下代碼到CRM我得到一個錯誤:從SQL數據庫獲取信息並獲取登錄錯誤
錯誤代碼:
Warning: mysqli::mysqli(): (28000/1045): Access denied for user ''rylshiel_order'@'localhost' (using password: YES) in /home4/rylshieldltd/public_html/sandgcrm/dashboard.php on line 216
Connection failed: Access denied for user ''rylshiel_order'@'localhost' (using password: YES)
我已經檢查和複查幾次,我使用該連接的憑據是正確的我甚至給定第二個用戶在數據庫上擁有完全權限,並再次用相同的錯誤代碼進行測試。
我的代碼如下:
<?php
$servername = "localhost";
$username = "'rylshiel_order";
$password = "Z]r^0FLF2,NC";
$dbname = "rylshiel_sandg";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT Customername, Material, Quantity, Delivery, TotalCost, Paid FROM Orders";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
echo "<table class='table table-hover'><tr style='font-size:18px;'><th style='text-align:center;'>Add User</th><th style='text-align:center;'>Edit User</th><th style='text-align:center;'>Remove User</th><th style='text-align:center;'>Unlock All</th><th style='text-align:center;'>View Locked</th><th style='text-align:center;'>File Permissions</th></tr>";
// output data of each row
while($row = $result->fetch_assoc()) {
echo "<tr style='font-size:16px; text-align:center;'><td><input type='checkbox' disabled".$row["Customername"]."></td><td><input type='checkbox' disabled".$row["Material"]."></td><td><input type='checkbox' disabled".$row["Quantity"]."></td><td><input type='checkbox' disabled". ($row["Delivery"] == 'YES' ? " checked" : "") ."></td><td><input type='checkbox' disabled".["TotalCost"]."></td><td><input type='checkbox' disabled". ($row["Paid"] == 'YES' ? " checked" : "") ."></td></tr>";
}
echo "</table>";
} else {
echo "There are 0 orders in the system";
}
$conn->close();
?>
由於這是與登錄信息和問題顯然密碼有誤我已經離開了憑據,如果沒有與我的代碼中的錯誤,然後我會改變這個。
我怎樣才能讓錯誤消失?
您的用戶名*確實*是否以撇號開頭? '$用戶名=「'rylshiel_order」;' – CD001