第二次使用 POST 值时:supplier,脚本不会写入数据库。如果没有第二个实例,一切都会按预期写入。我究竟做错了什么?$hostdb = 'localhost';$namedb = 'dbname';$userdb = 'username';$passdb = 'password';$charset = 'utf8'; if (isset($_POST['name'], $_POST['type'] , $_POST['number'] ,$_POST['supplier'] )) { // Connect and create the PDO object $options = [ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_EMULATE_PREPARES => false, ]; $conn = new PDO("mysql:host=$hostdb;dbname=$namedb;charset=$charset", $userdb, $passdb, $options); try{ $conn->beginTransaction(); $stmt = $conn->prepare( ' INSERT INTO `Equipment` (name, type, number, supplier, status, managed_by )VALUES (:name,:type,:number,:supplier,"Ready", :supplier) ' ); $stmt->execute([ 'name' => $_POST['name'], 'type' => $_POST['type'], 'number' => $_POST['number'], 'supplier' => $_POST['supplier'], ]);
1 回答
- 1 回答
- 0 关注
- 101 浏览
添加回答
举报
0/150
提交
取消