I’m trying to use a simple UPDATE query with pdo but after 5 hours of looking at the problem I just lost it. Maybe some of you guys know what I’m doing wrong.
I’m always getting this error:
“10-24 17:59:08.829: D/test(1794): Warning: PDOStatement::execute() [pdostatement.execute]: SQLSTATE[HY093]: Invalid parameter” number: parameter was not defined
$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));
My mysql table looks like this:
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)
You have 14 parameters in the query but only 13 in the execute array. It appears as though the isTournament parameter is missing from the array.