简体   繁体   English

错误:“字段列表”中的未知列“日期”

[英]Error: Unknown column 'Date' in 'field list'

I am working on a blood bank data base but i am repeatedly getting a Error: Unknown column 'Date' in 'field list'.there is no spelling error in either php or mysql so here is my php code 我正在血库数据库上工作,但是我反复得到一个错误:“字段列表”中的未知列“日期”。php或mysql中没有拼写错误,因此这是我的php代码

<?php
    $con=mysqli_connect("localhost","root","","bloodbank");
    // Check connection
   if (mysqli_connect_errno())
   {
   echo "Failed to connect to MySQL: " . mysqli_connect_error();
   }

   $sql="INSERT INTO users       (First,Last,Date,Email,Contact,Bloodgroup,Gender,address,City,username,password)
    VALUES
    ('$_POST[first]','$_POST[last]','$_POST[dob]','$_POST[email]','$_POST[contact]','$_POST[bg]',
'$_POST[sex]','$_POST[address]','$_POST[city]','$_POST[username]','$_POST[password]')";

    if (!mysqli_query($con,$sql))
    {
    die('Error: ' . mysqli_error($con));
    }
    echo "1 record added";

    mysqli_close($con);
    ?></code>

Basic explanation would be that Your query does not matches with your table structure 基本的解释是您的查询与您的表结构不匹配

INSERT INTO users(First,Last,Date
                             ^ // Right here you are using it

Check your table structure using tools like phpMyAdmin and if the field does exist, Date is a reserved word so that might be creating the problem. 使用phpMyAdmin之类的工具检查您的表结构,如果该字段确实存在,则Date是保留字,因此可能会造成问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM