使用mysql和php插入数据问题

时间:2017-07-26 10:50:19

标签: php mysql sql insert sql-insert

此代码必须正常工作,但事实并非如此。当我在mysql workbench上使用echo $ sql查询时,它实际上将数据添加到数据库中。我认为有一些关于mysql_query方法的东西。已经有两天我正在努力解决这个问题,一点点的帮助会很棒。

这是代码

    <?php 


     if ($_SERVER["REQUEST_METHOD"]=="POST") {
     include('mysqli_connect.php');



    $AracMarkasi = mysqli_real_escape_string($conn, $_POST['AracMarkasi']);
    $AracPlakasi = mysqli_real_escape_string($conn, $_POST['AracPlakasi']);
    $AracRengi = mysqli_real_escape_string($conn, $_POST['AracRengi']);
    $AracModeli = mysqli_real_escape_string($conn, $_POST['AracModeli']);
    $AracSahibiAdi = mysqli_real_escape_string($conn, 
    $_POST['AracSahibiAdi']);
    $AracSahibiSoyadi = mysqli_real_escape_string($conn, 
    $_POST['AracSahibiSoyadi']);
    $AracSahibiAdresi = mysqli_real_escape_string($conn, 
    $_POST['AracSahibiAdresi']);
    $AracSahibiTC = mysqli_real_escape_string($conn, 
    $_POST['AracSahibiTC']);
    $DosyaNO = mysqli_real_escape_string($conn, $_POST['DosyaNO']);
    $IcraDairesiNO = mysqli_real_escape_string($conn, 
    $_POST['IcraDairesiNO']);
    $Durum = mysqli_real_escape_string($conn, $_POST['Durum']);




    $sql = "INSERT INTO deptcar.arac_tablosu (AracPlakası,AracMarkasi,AracModeli,AracRengi,AracSahibiAdi,AracSahibiSoyadi,AracSahibiTCKimlik,AracSahibiAdresi,AracDurum,DosyaNO,IcraDairesiNO) VALUES('$AracPlakasi','$AracMarkasi','$AracModeli','$AracRengi','$AracSahibiAdi','$AracSahibiSoyadi','$AracSahibiTC','$AracSahibiAdresi','$Durum','$DosyaNO','$IcraDairesiNO')";

    echo "$sql";

    $result = mysqli_query($conn,$sql);

    echo "$result";

    if(!$result)
    { die('Could not enter data: ' . mysql_error());}
    else{echo "Entered data successfully\n";}

    mysql_close($conn);
    }
    ?>

这部分是输出

  

已连接

     

INSERT INTO deptcar.arac_tablosu   (AracPlakası,AracMarkasi,AracModeli,AracRengi,AracSahibiAdi,AracSahibiSoyadi,AracSahibiTCKimlik,AracSahibiAdresi,AracDurum,DosyaNO,IcraDairesiNO)   VALUES( '广告', '广告', 'YT', '', '大鼠高血压相关基因', '汞柱', 'DHG', 'GGD', 'SahaPersoneli', 'GFH', 'HDG')

     

无法输入数据:

0 个答案:

没有答案