我正在尝试将数据记录到我的数据库中,但我一直收到以下错误:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'firstName' in 'field list'
我做过研究但仍未找到答案。我的代码中是否有任何看不见的错误?难道我做错了什么?我不明白为什么我收到此错误,我的数据库确实有一个名为firstName的列。感谢。
$db = new PDO('mysql:host=localhost;dbname=bord','root','root');
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "INSERT INTO users (firstName, lastName, password, email, code, active, month) VALUES (
:firstName, :lastName, :password, :email, :code, :active, :month
)";
$statement = $db->prepare($sql);
$statement->bindParam(':firstName', $firstName);
$statement->bindParam(':lastName', $lastName);
$statement->bindParam(':password', $password);
$statement->bindParam(':email', $email);
$statement->bindParam(':code', $code);
$statement->bindParam(':active', $active);
$statement->bindParam(':month', $month);
$firstName = 'Mitchell';
$lastName = "Sanders";
$password = "password";
$email = "msandy@fakemail.com";
$code = 12345;
$active = 0;
$month = date("F");
$statement->execute();