我目前对下面的代码有问题..
它一直在说
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[23000]:
Integrity constraint violation: 1048 Column 'Firstname' cannot be null'
in C:\xampp\htdocs\clubresults\checkregister.php:30 Stack trace: #0
C:\xampp\htdocs\clubresults\checkregister.php(30): PDOStatement->execute()
#1 {main} thrown in C:\xampp\htdocs\clubresults\checkregister.php on line 30
我已经尝试了我所知道的一切,但我就是无法消除该错误......任何形式的帮助都非常感谢:D 这个 php 文件称为 checkregister.php
$pdo = new PDO('mysql:host=localhost;dbname=clubresults', 'root', '12345678');
#Set Error Mode to ERRMODE_EXCEPTION.
$pdo->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $pdo->prepare('INSERT INTO members
(firstname, surname, DD, MM, YYYY,
email, Player1, Player2, Player3, Player4, Player5)
VALUES
(:firstname, :surname, :DD, :MM, :YYYY,
:email, :Player1, :Player2, :Player3, :Player4, :Player5)');
$stmt->bindParam(':firstname', $_GET['firstname']);
$stmt->bindParam(':surname', $_GET['surname']);
$stmt->bindParam(':DD', $_GET['DD']);
$stmt->bindParam(':MM', $_GET['MM']);
$stmt->bindParam(':YYYY', $_GET['YYYY']);
$stmt->bindParam(':email', $_GET['email']);
$stmt->bindParam(':Player1', $_GET['Player1']);
$stmt->bindParam(':Player2', $_GET['Player2']);
$stmt->bindParam(':Player3', $_GET['Player3']);
$stmt->bindParam(':Player4', $_GET['Player4']);
$stmt->bindParam(':Player5', $_GET['Player5']);
$stmt->execute();
这是我在另一个 php 文件中的表单:
<form name="register" method="post" action="checkregister.php">
<!--Text, using <p> tag for new line-->
Main Account Registration <p>
* All Fields Mandatory <P>
<div class="required_field">
<label for="leadername">Team Leader's First Name</label>
<input name="firstname" type="text" value="hihi"><p>
<span id="firstnameerror" class="error"></span>
</div>
the same code repeats for each of the other ones such as Surname, DD MM YY, etc
<input type="submit" name="submitbutton" id="submitbutton" value="Register">
<input type="reset" name="resetbutton" id="resetbutton" value="Clear all Fields">
</form>