我在将数据插入数据库时​​遇到问题,但没有显示任何错误

我在将我的数据插入数据库时遇到问题,通常如果出现问题,它会显示错误,但这个没有显示错误(我不知道这是否算作错误,因为我还是这个 php 编码的新手)


<?php

    /*proses*/


    $conn = mysqli_connect('localhost','root', '','dsolo');

    // Check connection

    if (!$conn) {


    die("Connection failed: " . mysqli_connect_error());

    }





        $id = $_POST['id'];

        $bulan = $_POST['bulan'];

        $gajipokok = $_POST['gajipokok'];

        $totalbonus = $_POST['totalbonus'];

        $potongan = $_POST['potongan'];

        $totalgaji = $_POST['totalgaji'];

        $pajak = $_POST['pajak'];

        $tes="INSERT INTO gaji set id='$id',

                                   bulan='$bulan',

                                   gajipokok='$gajipokok',

                                   totalbonus='$totalbonus',

                                   potongan='$potongan',

                                   totalgaji='$totalgaji',

                                   pajak='$pajak',";

        mysqli_query ($conn,$tes) or die ($tes);


?>

在我按下保存后显示的是这个


INSERT INTO gaji set id='yuki', bulan='2019-08', gajipokok='2000000', totalbonus='2000000', potongan='1000000', totalgaji='3000000', pajak='300000',

我需要在代码中更改什么?


红糖糍粑
浏览 148回答 1
1回答

明月笑刀无情

,你的查询中有一个额外的,你可以删除它,你的代码看起来像下面的代码..<?php&nbsp; &nbsp; &nbsp;$conn = mysqli_connect('localhost','root', '','dsolo');&nbsp; &nbsp; &nbsp;// Check connection&nbsp; &nbsp; &nbsp;if (!$conn)&nbsp;&nbsp; &nbsp; &nbsp;{&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;die("Connection failed: " . mysqli_connect_error());&nbsp; &nbsp; &nbsp;}&nbsp; &nbsp; &nbsp;else&nbsp; &nbsp; &nbsp;{&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$id = $_POST['id'];&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$bulan = $_POST['bulan'];&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$gajipokok = $_POST['gajipokok'];&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$totalbonus = $_POST['totalbonus'];&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$potongan = $_POST['potongan'];&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$totalgaji = $_POST['totalgaji'];&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$pajak = $_POST['pajak'];&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$tes="INSERT INTO gaji set id='$id', bulan='$bulan', gajipokok='$gajipokok', totalbonus='$totalbonus',potongan='$potongan', totalgaji='$totalgaji', pajak='$pajak'";&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;mysqli_query ($conn,$tes) or die ($tes);&nbsp; &nbsp; }?>
打开App,查看更多内容
随时随地看视频慕课网APP