我想做一个注册系统,但当我试图访问localhost上的页面时,它会这样告诉我:
致命错误:在第3行的C:\wamp64\www\Fireblock\index.php中PDOException:在第3行的C:\wamp64\www\Fireblock\index.php中
Idk第三行有什么问题,因为我遵循的是教程oof
我的php脚本:
<?php
try {
$bdd = new PDO('mysql:host=127.0.0.1;dbname=fireblock;', 'root', ''); //where is the error
if (isset($_POST['submitform'])) {
$username = htmlspecialchars($_POST['username']);
$email = htmlspecialchars($_POST['email']);
$email2 = htmlspecialchars($_POST['email2']);
$pass = password_hash($_POST['password']);
$pass2 = password_hash($_POST['password2']);
if (!empty($_POST['username']) AND !empty($_POST['password']) AND !empty($_POST['password2'])) {
$usernamelength = strlen($username);
if ($usernamelength <= 255) {
if ($email == $email2) {
if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
if ($password == $password2) {
$insertmember = $bdd->prepare("INSERT into members(username, email, password) VALUES(?, ?, ?)");
$insertmember->execute(array(
$username,
$email,
$password
));
$error = "Your account has been created!";
} else {
$error = "Your passwords aren't the same!";
}
} else {
$error = "Your email address isn't valid!";
}
} else {
$error = "Your emails aren't the same!";
}
} else {
$error = "Your username can't be higher than 255 characters!";
}
} else {
$error = "Every fields should be completed!";
}
}
} catch (PDOException $ex) {
print $ex->getMessage();
}
?> 我把所有的PHP部分
发布于 2020-11-01 02:14:45
试一试
$bdd = new PDO('mysql:host=127.0.0.1;dbname=fireblock', 'root', '');我在最后一个键/值对的末尾(fireblock之后)删除了一个分号,因为在我用来与您的代码进行比较的任何代码示例中都没有使用分号。
https://stackoverflow.com/questions/64624602
复制相似问题