Php 表单无法向 phpMyAdmin 提交信息

标签 php mysql

我从我之前工作的学生那里继承了这段乱七八糟的代码。我相信它可以用更有效和更简单的方式编写,但我不确定如何清理它。我希望通过以更好的方式编写它,我可能会发现阻止提交表单数据的错误。

$statement = db::getInstance()->prepare('INSERT INTO `Training_Log` (
`Trainees_Name`,
`Date`,
`Time`,
`Bus_Number`,
`Trainer`,
`Training_Shift_Number`,
`Number_of_Hours`,
`Total_Number_of_Hours`,
`Static_Comments`,
`PreTrip_Comments`,
`Road_Driving_Comments`,
`RailRoad_Comments`,
`Bus_Stop_Comments`,
`Route_Comments`, )
     VALUES(NOW(), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)');

    $statement->bind_param('sssiiiissssss', $_SERVER['HTTP_CAS_USER'],    
    $_POST['sec1_trainee'], $_POST['sec1_trainer'], $_POST['sec1_datetime'], 
    $_POST['sec1_bus'], $_POST['sec1_shiftnum'], $_POST['sec1_numhour'], 
    $_POST['sec1_totnumhour'], $_POST['static'], $_POST['pretrip'], 
    $_POST['roaddriving'], $_POST['railroad'], $_POST['busstop'], $_POST['routes']);

    $statement->execute();
    $statement->close();

最佳答案

删除插入列列表中的尾随逗号。

`Route_Comments`, )

应该是

`Route_Comments`)

(可能还有其他问题。比如您将 DATE 插入到名为 *_name 的字段中?)

您没有看到任何错误,因为您没有检查任何错误。 http://us3.php.net/manual/en/pdo.errorinfo.php

关于Php 表单无法向 phpMyAdmin 提交信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20979105/

相关文章:

php - 在mysql中查找重复记录

php - 是否可以计算 PDO 准备语句中的参数数量?

php - 在 php 中解析子域的字符串

PHP删除以wp_postpass_开头的cookie

mysql - MySQL 上的 URL 正则表达式搜索和替换(在 WordPress 中)

mysql COUNT() 在 php 中

mysql - Toad for Mysql Server - 连接到远程主机时出现错误的握手错误

php - mailchimp php 集成

php - Ubuntu Linux VPS 上的 SQLSTATE[01002] Adaptive Server 连接失败(严重性 9)错误

MySQL 存储过程 SELECT、三个 WHERE CLAUSE 值和 ORDER BY