0

I have tried to build an insert statement. The code is run without any mistake but the data will not store into the database. But I can't see what the problem is. Here my code...

if (isset($_POST["submit_eingabemaskeR"]))
{
    $tore = $_POST['tore'];
    $note = $_POST['note'];
    $spielPlan = $_POST['SpielerNummer'];
    $spielerID = "123";

    $pdoInsert = new PDO('mysql:host=localhost;dbname=tmp_bundesliga;charset=utf8mb4', 'root');
    $sqlInsert = "INSERT into `SpielerStats` ('Player_ID', 'Note', 'Tore', 'Spielplan_ID') VALUES (:tore, :note, :spielPlanID, :spielerID)";
    $pdoResult = $pdoInsert->prepare($sqlInsert);

    $pdoExec = $pdoResult->execute(array(":tore"=>$tore, ":note"=>$note, ":spielPlanID"=>$spielPlan, ":spielerID"=>$spielerID));

    if($pdoExec){
        echo 'Data insert';
    }else{
        echo 'Data not insert';
    }
}

Thank you for helping me!

HansMuff
  • 299
  • 1
  • 8
  • 22
  • Wrong quotes around column names. – Jonnix Jul 04 '17 at 11:03
  • Oh, yes thank you. I got it. But I have another question. In the input field note, I fill in the decimal number 2.5. In the variable $note is 2.5 stored but in the mysql db there is 3, because of rounding. What must I change to get the right result in the db? – HansMuff Jul 04 '17 at 12:15
  • Is your DB column set to INT instead of a floating-point type? – Jonnix Jul 04 '17 at 12:16

0 Answers0