0
我想我的腳本連接到數據庫並在其中插入一個簡單的apikey。問題在於腳本連接到數據庫。我在我的電腦上安裝了xampp安裝腳本。PHP腳本無法連接到sql數據庫
腳本:
<?php
$servername = "127.0.0.1";
$username = "[email protected]";
$password = "root";
$dbname = "apikey";
// Create a connection to the server
$conn = new mysqli ($servername, $username, $password, $dbname);
// Check the connection to the server
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "INSERT INTO APIkey (APIkey)
VALUES ('John Doe')";
if ($conn->query($sql) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " .$sql. "<br>" . $conn->error;
}
$conn->close();
?>
有沒有人有一個想法可能是錯誤的腳本?
謝謝你的任何建議。