0

テーブルにデータを挿入しようとしています。テーブル構造は

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 の場合、コードは失敗します。

4

1 に答える 1

0

次の選択ステートメントの選択

idf_votante             varchar(25) NO          

$sqlAgregarVoto = "INSERT INTO ws_deta_votaciones (`id_participante`, `idf_votante`, `periodo`, `estado`) VALUES(?,?,?,?);";

$b= 89;

$stmt->bind_param( 'iiis',$a,$b,$c,$valorEstado)

varchar(25) として定義されている idf_votante に整数を挿入しようとしているようです。

于 2013-09-13T00:43:57.353 に答える