PHP PDO插入参数不起作用

时间:2014-04-15 22:15:59

标签: php mysql pdo

我完全不知道为什么这个PDO插件在直接添加但不作为参数添加时正常工作。这是什么工作:

$stmt = $conn->prepare("INSERT INTO class_mh_q
                              (MH_ID, Question, Answer, Comments)
                        VALUES
                              ('$modID','$thisQID','$thisQAnswer','$thisComment')
                        ");
$stmt->execute();

但是,这不起作用:

$stmt = $conn->prepare("INSERT INTO class_mh_q
                              (MH_ID, Question, Answer, Comments)
                        VALUES
                              (:mh_id, :q_id, :answer, :comment)
                        ");

$params = array( ':mh_id' => $modID,
                 ':q_id' => $thisQID,
                 ':answer' => $thisQAnswer,
                 ':comment' => $thisComment
               );
$stmt->execute($params);

任何人都知道我的设置有什么问题?

0 个答案:

没有答案