我正在尝试将数据插入表中。表结构是
Field Type Null Key Default Extra
id_registro bigint(20) NO PRIMARY Auto_Increment
id_participante int(11) NO
idf_votante varchar(25) NO
periodo int(8) NO
estado char(1) NO P
registrado timestamp NO CURRENT_TIMESTAMP
我的PHP代码是:
<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
include "lib/database.config.php"; //database config
$mysqli = new mysqli($db['host'], $db['user'], $db['password'], $db['database']);
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$sqlAgregarVoto = "INSERT INTO ws_deta_votaciones (`id_participante`, `idf_votante`, `periodo`, `estado`) VALUES(?,?,?,?);";
$valorPeriodo = 20120101;
$valorEstado = 'P';
$a = 1;
$b= 89;
$c = 20120101;
if ($stmt = $mysqli->prepare($sqlAgregarVoto) ){
//$stmt->bind_param( 'iiis',$_REQUEST['idp'],$_REQUEST['idvf'],$valorPeriodo,$valorEstado)
$stmt->bind_param( 'iiis',$a,$b,$c,$valorEstado)
$stmt->execute();
} else {
throw new Exception($stmt->error);
}
?>
代码失败,有大约 500 个内部错误。
bind_params 时代码失败。