我在尝试访问我的数据库时遇到此解析错误。 我得到的错误是“解析错误:语法错误,意外';'在第9行的C:\ xampp \ htdocs \ login \ database.php中“
这是我的database.php代码
<?php
$server = 'localhost';
$username = 'root';
$password = 'root';
$database = 'login';
try
{
$conn = new PDO("mysql:host=$server;dbname=$login"; $username, $password);
}
catch(PDOException $e);
{
die("Connection failed: " . $e->getMessage());
}
?>
我的网页代码是
<?php
require 'database.php';
if(!empty($_POST['username']) && !empty(@_POST['password'])):
endif;
?>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/style.css">
<link href="https://fonts.googleapis.com/css?family=Comfortaa" rel="stylesheet">
<title> Rineva Call Managment - Home -
</title>
</head>
<body>
<header>
<h1>Rineva Call Managment System</h1>
</header>
<section>
<h3> Please Register User's here </h3>
<form action="register.php" method="POST">
<input type="text" placeholder="Username" name="username">
<input type="password" placeholder="Password" name="password">
<input type="password" placeholder="Confirm Password" name="confirm_password">
<input type="submit" value="Register">
</section>
</body>
</html?
答案 0 :(得分:-1)
错误在于:
try {
$conn = new PDO("mysql:host=$server;dbname=$login", $username, $password);
//error was at this line
}
catch(PDOException $e){
die("Connection failed: " . $e->getMessage());
}