嗨,我正在从正常的做事方式转变为这种“新”对象方式......我不会说谎,我很困惑,希望有人能在这里帮助我......
下面是我的代码
<?php
include("common/functions.inc.php");
$mysqli = new MySQLi($settings['mysql']['host'], $settings['mysql']['user'], $settings['mysql']['pass'], $settings['mysql']['db']);
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
if($stmt = $mysqli->prepare("INSERT INTO tbl_survey (fld_submituid, fld_q1answer, fld_q2answer, fld_q3answer, fld_q4answer, fld_q5answer, fld_q6answer) VALUES (:uid, :q1, :q2, :q3, :q4, :q5, :q6)")) {
$stmt->bindParam(":uid",$uid, PDO::PARAM_INT);
$stmt->bindParam(":q1",$q1, PDO::PARAM_STR, 12);
$stmt->bindParam(":q2",$q2, PDO::PARAM_STR, 12);
$stmt->bindParam(":q3",$q3, PDO::PARAM_STR, 12);
$stmt->bindParam(":q4",$q4, PDO::PARAM_STR, 12);
$stmt->bindParam(":q5",$q5, PDO::PARAM_STR, 12);
$stmt->bindParam(":q6",$q6, PDO::PARAM_STR, 12);
$uid = 1;
$q1 = "q1";
$q2 = "q2";
$q3 = "q3";
$q4 = "q4";
$q5 = "q5";
$q6 = "q6";
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
if($stmt->execute()) {
echo 'true';
} else {
echo 'false';
}
} else {
echo 'fail';
}
我仍然不知道为什么我的代码失败了,请有人帮助我吗?谢谢