1

我正在尝试对 pdo 使用简单的 UPDATE 查询,但在查看问题 5 小时后,我只是丢失了它。也许你们中的一些人知道我做错了什么。

我总是收到此错误:“10-24 17:59:08.829: D/test(1794): Warning : PDOStatement::execute() [pdostatement.execute]: SQLSTATE[HY093]: Invalid parameter” number: parameter未定义

$name = $_POST['name'];
$buyin = $_POST['buyin'];
$result = $_POST['result'];
$startDate = $_POST['startDate'];
$endDate = $_POST['endDate'];
$location = $_POST['location'];
$isTournament = $_POST['isTournament'];
$participants = $_POST['participants'];
$endPosition = $_POST['endposition'];
$comment = $_POST['comment'];
$blinds = $_POST['blinds'];
$pause = $_POST['pause'];

$game_id = $_POST['game_id'];
$user_id = $_POST['user_id'];


try {
    $dbconn = 'mysql:host=' . DBHOST . ';dbname=' . DBDATA;
    $db = new PDO($dbconn, DBUSER, DBPASS);
} catch (PDOException $e) {
    echo 'Connection failed: ' . $e->getMessage();
}

$sql = 'UPDATE game SET name = :name AND buyin = :buyin AND result = :result AND startDate = :startDate AND endDate = :endDate AND
location = :location AND isTournament = :isTournament AND participants = :participants AND endposition = :endposition AND comment = :comment AND blinds = :blinds AND pause = :pause
WHERE game_id = :game_id AND user_id = :$user_id';
$statement = $db->prepare($sql);

$boolean = $statement->execute(array(':name' => $name, ':buyin' => $buyin, ':result' => $result,':startDate' => $startDate, ':endDate'
=>$endDate, ':location'=> $location, ':participants'=> $participants, ':endposition' => $endPosition, ':comment' => $comment, ':blinds' => $blinds, ':pause' => $pause, ':game_id' => $game_id,':user_id' => $user_id));

我的 mysql 表如下所示:

Naam    Type    
 1  game_id int(11)         
 2  user_id int(11)         
 3  name    varchar(45) 
 4  buyin   double          
 5  result  double          
 6  startDate   bigint(20)      
 7  endDate bigint(20)          
 8  location    
 9  isTournament    
 10 participants    
 11 endposition 
 12 comment text    
 13 blinds  text    
 14 pause   bigint(20)
4

1 回答 1

6

查询中有 14 个参数,但执行数组中只有 13 个。似乎数组中缺少 isTournament 参数。

于 2012-10-24T17:48:33.413 回答