0

I have a small form which submits data to a database and shows it back on the screen again. I've got it almost working, but I'm struggling with dots (.) and comma's (,) in a textfield in PHP. Whenever I put in 77.50 or 77,50 as a value in a PHP textfield, nothing is submitted to the database. When I just enter 77, everything goes well and it's submitted. If I type the query in SQL self all goes well too:

INSERT INTO prijzen (inkoopprijs) VALUES ('77.50');

I have tried the following anwswers in the topics below with no luck:

I have no idea what I'm doing wrong. Probably something silly I forgot to do...

Here is the code/column I use for the decimal bit: The column in the database:

  • Name: inkoopprijs
  • type: DECIMAL (5,2)
    $inkoopprijs = filter_input(INPUT_POST,"inkoopprijs",FILTER_SANITIZE_NUMBER_FLOAT);
    $iQuery = $conn->prepare("INSERT INTO prijzen (inkoopprijs) VALUES (:inkoopprijs)");
    $iQuery->bindParam("inkoopprijs", $inkoopprijs);
        
    If ($iQuery->execute())
        {
            echo "Added to the database.";
        }
    Else
        {
            echo "Something went wrong.";
        }

    echo "<td><font color=black font face='Chiller' font size = '6'>" . "\xE2\x82\xAc" . number_format($data["inkoopprijs"],2,",",".") . "</font></td>";

        
Sub
  • 55
  • 1
  • 9

0 Answers0