<?php
include_once('dbcon.php');
if (isset($_POST['name'])) {
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$stmt =$pdo->prepare("INSERT INTO users(name,email,phone) VALUES (:name,:email,:phone)");
$stmt->bindParam(':name', $name);
$stmt->bindParam(':email', $email);
$stmt->bindParam(':phone', $phone);
$stmt->execute();
}
?>
This is my code it's super simple the database works and all but I was trying to add another table that didn't work to it and it flopped and I messed something up on line 11 I think, any help would be extremely appreciated, thanks in advance !
这是我的代码它是超级简单的数据库工作,但我只是试图添加另一个不起作用的表,它失败了,我在第11行搞砸了一些东西,我想,任何帮助都会非常感激,谢谢提前!
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '0' for key 'PRIMARY'' in E:\utsdata\2T\2809984199\GsoVerk4\register.php:11 Stack trace: #0 E:\utsdata\2T\2809984199\GsoVerk4\register.php(11): PDOStatement->execute() #1 {main} thrown in E:\utsdata\2T\2809984199\GsoVerk4\register.php on line 11
致命错误:带有消息'SQLSTATE [23000]的未捕获异常'PDOException':完整性约束违规:1062 E:\ utsdata \ 2T \ 2809984199 \ GsoVerk4 \ register.php中的键'PRIMARY'重复输入'0':11堆栈跟踪:#0 E:\ utsdata \ 2T \ 2809984199 \ GsoVerk4 \ register.php(11):PDOStatement-> execute()#1 {main}抛出E:\ utsdata \ 2T \ 2809984199 \ GsoVerk4 \ register.php on第11行
This is the error that I get
这是我得到的错误
1 个解决方案
#1
1
Seems you forgot to make your PRIMARY KEY
column autoincrement
-ing
似乎你忘了让你的PRIMARY KEY栏自动增量
#1
1
Seems you forgot to make your PRIMARY KEY
column autoincrement
-ing
似乎你忘了让你的PRIMARY KEY栏自动增量