Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
122 views
in Technique[技术] by (71.8m points)

php - Problem in an Insert : values list are not matching column list

So basically, I have to retrieve the primary keys of two tables which are linked by a multiple association (if the name in the "joueur" table matches the name in the "match_rencontre" table, then i select their IDs. And then I have to insert these keys into the table "participer", to find out who are the players who participated

here is my database, i'm working on xampp, so if you wanna test it : http://www.filedropper.com/wszzzzcebasketsql

enter image description here

The error i get is : "Error : SQLSTATE[21S01]: Insert value list does not match column list: 1136 Column count doesn't match value count at row 1 " I don't want to insert something into "note" and "titulaire" for the moment.

Thanks for your help

<?php
require('database.php');
global $db;
$req = $db->prepare("SELECT joueur.n_license, match_rencontre.id_match_rencontre FROM match_rencontre, joueur, participer WHERE  joueur.n_license = participer.n_license AND  participer.id_match_rencontre = match_rencontre.id_match_rencontre AND joueur.joue = match_rencontre.nom_equipe_adverse");

$req->execute();
while ($row = $req->fetch()) {
        $n_license = (int)$row['joueur.n_license'];
        $id_match_rencontre = (int)$row['match_rencontre.id_match_rencontre'];
    }
}

try {
    $query = "INSERT INTO participer(n_license, id_match_rencontre) VALUES ('$n_license','$id_match_rencontre')";
    $go=$db->prepare($query);
    $go->execute();
}   catch (PDOException $e) {
    echo 'Error : ' . $e->getMessage();
}
?>
question from:https://stackoverflow.com/questions/65602680/problem-in-an-insert-values-list-are-not-matching-column-list

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...