我新安装了Wamp Server,我正在尝试开发本地站点。我想要访问的数据库是Shopping。但是我在尝试访问它时遇到错误。有人可以帮忙吗?请告诉我这里写的不好? PS:我是PHP和Wamp Server环境的新手。谢谢!
<?php
$connect = mysqli_connect("localhost", "root", "gold", "shopping") or die
("Please, check the server connection.");
$email_address = $_POST['emailaddress'];
$password = $_POST['password'];
$repassword = $_POST['repassword'];
$completename = $_POST['complete_name'];
$address1 = $_POST['address1'];
$address2 = $_POST['address2'];
$city = $_POST['city'];
$state = $_POST['state'];
$country = $_POST['country'];
$zipcode = $_POST['zipcode'];
$phone_no = $_POST['phone_no'];
$sql = "INSERT INTO customers (email_address, password, complete_name,
address_line1, address_line2, city, state, zipcode, country, cellphone_no)
VALUES ('$email_address',(PASSWORD('$password')), '$completename', '$address1',
'$address2','$city', '$state', '$zipcode', '$country', '$phone_no')";
$result = mysqli_query($connect, $sql) or die(mysql_error());
if ($result)
{
?>
<p>
Dear, <?php echo $completename; ?> your account is successfully created
<?php
}
else
{
echo "Some error occurred. Please use different email address";
}
?>
答案 0 :(得分:1)
您的数据库是必需的密码,因此请检查数据库凭据并使用以下代码检查连接
<?php
$servername = "localhost";
$username = "username"; // set user name
$password = "password"; // set password
// Create connection
$conn = mysqli_connect($servername, $username, $password);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
echo "Connected successfully";
?>