“字段列表”中的未知列是什么意思?

时间:2013-06-27 12:45:33

标签: php html mysql database

这是我在html + php中的代码。每当我运行此页面并尝试在我的数据库的此表中输入时,会出现一条消息“字段列表中的未知列'phone_outlet'”..我该怎么办? :(我在代码中找不到任何错误?:(

这是我在数据库中的表 -

-- --------------------------------------------------------

--
-- Table structure for table `profile_company`
--

CREATE TABLE IF NOT EXISTS `profile_company` (
  `profile_id` varchar(250) NOT NULL,
  `name_business_profile` varchar(250) NOT NULL,
  `day` varchar(250) NOT NULL,
  `month` varchar(250) NOT NULL,
  `year` varchar(250) NOT NULL,
  `nationality` varchar(250) NOT NULL,
  `business_id` varchar(250) NOT NULL,
  `house_no` varchar(250) NOT NULL,
  `road_no` varchar(250) NOT NULL,
  `area_name` varchar(250) NOT NULL,
  `area_code` varchar(250) NOT NULL,
  `district` varchar(250) NOT NULL,
  `division` varchar(250) NOT NULL,
  `country` varchar(250) NOT NULL,
  `country_code` varchar(250) NOT NULL,
  `time_zone` varchar(250) NOT NULL,
  `phone_office` varchar(250) NOT NULL,
  `phone_outlet` varchar(250) NOT NULL,
  `phone_mobile` varchar(250) NOT NULL,
  `other_email_1` varchar(250) NOT NULL,
  `other_email_2` varchar(250) NOT NULL,
  `other_email_3` varchar(250) NOT NULL,
  `website_1` varchar(250) NOT NULL,
  `website_2` varchar(250) NOT NULL,
  `website_3` varchar(250) NOT NULL,
  `organization_1` varchar(250) NOT NULL,
  `organization_2` varchar(250) NOT NULL,
  `organization_3` varchar(250) NOT NULL,
  `nonprofit_1` varchar(250) NOT NULL,
  `nonprofit_2` varchar(250) NOT NULL,
  `nonprofit_3` varchar(250) NOT NULL,
  `currency_1` varchar(250) NOT NULL,
  `currency_2` varchar(250) NOT NULL,
  `currency_3` varchar(250) NOT NULL,
  `security_code_1` varchar(250) NOT NULL,
  `security_code_2` varchar(250) NOT NULL,
  `security_code_3` varchar(250) NOT NULL,
  `logo` varchar(250) NOT NULL,
  PRIMARY KEY (`profile_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

--
-- Dumping data for table `profile_company`
--


-- --------------------------------------------------------

这是我在php + html中的代码 -

<?php
session_start();
if(isset($_POST['submit']))
{
include("connection.php");

        $ProfileID=$_POST['pid'];
        $BusinessProfile=$_POST['prof'];


        $Day=$_POST['day'];
        $Month=$_POST['month'];
        $Year=$_POST['year'];


        $Nationality=$_POST['nat'];
        $BusinessID=$_POST['bid'];

        $HouseNo=$_POST['hno'];
        $RoadNo=$_POST['rno'];
        $AreaName=$_POST['area'];
        $AreaCode=$_POST['acode'];
        $District=$_POST['dis'];
        $Division=$_POST['div'];
        $Country=$_POST['country'];
        $CountryCode=$_POST['ccode'];
        $TimeZone=$_POST['time'];


        $PhoneOffice=$_POST['ophone'];
        $PhoneOutlet=$_POST['tphone'];
        $PhoneMobile=$_POST['mphone'];

        $Email1=$_POST['email1'];
        $Email2=$_POST['email2'];
        $Email3=$_POST['email3'];

        $Website1=$_POST['web1'];
        $Website2=$_POST['web2'];
        $Website3=$_POST['web3'];

        $Organization1=$_POST['org1'];
        $Organization2=$_POST['org2'];
        $Organization3=$_POST['org3'];

        $NonProfit1=$_POST['non1'];
        $NonProfit2=$_POST['non2'];
        $NonProfit3=$_POST['non3'];

        $Currency1=$_POST['curr1'];
        $Currency2=$_POST['curr2'];
        $Currency3=$_POST['curr3'];

        $SecurityCode1=$_POST['scode1'];
        $SecurityCode2=$_POST['scode2'];
        $SecurityCode3=$_POST['scode3'];


        $strFilename1=$_FILES['strFile1']['tmp_name'];
        $Photo=$_FILES['strFile1']['name'];
        $file_name1=$Photo; 






        if(is_uploaded_file($strFilename1))
            {
             if(move_uploaded_file($strFilename1,"UserCompany/$file_name1"))
                {
                    $result=mysql_query("INSERT INTO profile_individual(profile_id,name_business_profile,day,month,year,nationality,
                                                                        business_id,house_no,road_no,area_name,area_code,district,division,
                                                                        country,country_code,time_zone,phone_office,phone_outlet,phone_mobile,other_email_1,
                                                                        other_email_2,other_email_3,website_1,website_2,website_3,organization_1,
                                                                        organization_2,organization_3,nonprofit_1,nonprofit_2,nonprofit_3,currency_1,currency_2,
                                                                        currency_3,security_code_1,security_code_2,security_code_3,logo)
                    VALUES('$ProfileID','$BusinessProfile','$Day','$Month','$Year','$Nationality','$BusinessID',
                           '$HouseNo','$RoadNo','$AreaName','$AreaCode','$District','$Division','$Country','$CountryCode','$TimeZone','$PhoneOffice',
                           '$PhoneOutlet','$PhoneMobile','$Email1','$Email2','$Email3','$Website1','$Website2','$Website3','$Organization1',
                           '$Organization2','$Organization3','$NonProfit1','$NonProfit2','$NonProfit3','$Currency1','$Currency2','$Currency3',
                           '$SecurityCode1','$SecurityCode2','$SecurityCode3','$Photo')");

                    if($result)
                    {
                        header("Location: home.php");
                    }
                    else
                    {
                        echo "Failed!";
                    } 

                }  
            }

            echo mysql_error();

}
?>



<!doctype html>
<html>
<head>



<style type="text/css">

</style>


<h1>  <center> Edit Your Business Profile </center> </h1>

</head>

<body>
<form action="" method="POST" enctype="multipart/form-data">

    <table>

    <tr>
        <td> <b> *Profile ID [Anything Unique]: </b></td>
        <td> <input type="text" name="pid" placeholder=""/> </td>
    </tr>

    <tr>
        <td> <b> *Business Profile Name: </b></td>
        <td> <input type="text" name="prof" placeholder=""/> </td>
    </tr> 



    <tr>
        <td> <b> __________________________ </b> </td>
        <td> <b> __________________ </b> </td>
    </tr>
    <tr>
        <td> <b> *Basic Information </b></td>
    </tr> 



    <tr>
            <td> <b> Date of Establishment: </b> </td> 
            <td> <select name="day" aria-label="Day"> 
            <option value="-1">Day:</option>
            <option value="1">1</option>
            <option value="2">2</option>
            <option value="3">3</option>
            <option value="4">4</option>
            <option value="5">5</option>
            <option value="6">6</option>
            <option value="7">7</option>
            <option value="8">8</option>
            <option value="9">9</option>
            <option value="10">10</option>
            <option value="11">11</option>
            <option value="12">12</option>
            <option value="13">13</option>
            <option value="14">14</option>
            <option value="15">15</option>
            <option value="16">16</option>
            <option value="17">17</option>
            <option value="18">18</option>
            <option value="19">19</option>
            <option value="20">20</option>
            <option value="21">21</option>
            <option value="22">22</option>
            <option value="23">23</option>
            <option value="24">24</option>
            <option value="25">25</option>
            <option value="26">26</option>
            <option value="27">27</option>
            <option value="28">28</option>
            <option value="29">29</option>
            <option value="30">30</option>
            <option value="31">31</option>
        </select> <!--/td>

        <td--> <select name="month" aria-label="Month">
            <option value="-1">Month:</option>
            <option value="1">Jan</option>
            <option value="2">Feb</option>
            <option value="3">Mar</option>
            <option value="4">Apr</option>
            <option value="5">May</option>
            <option value="6">Jun</option>
            <option value="7">Jul</option>
            <option value="8">Aug</option>
            <option value="9">Sep</option>
            <option value="10">Oct</option>
            <option value="11">Nov</option>
            <option value="12">Dec</option>
        </select> <!--/td>

<td--> 
<select name="year" aria-label="Year">
<option value="-1">Year:</option>
<option value="2013">2013</option>
<option value="2012">2012</option>
<option value="2011">2011</option>
<option value="2010">2010</option>
<option value="2009">2009</option>
<option value="2008">2008</option>
<option value="2007">2007</option>
<option value="2006">2006</option>
<option value="2005">2005</option>
<option value="2004">2004</option>
<option value="2003">2003</option>
<option value="2002">2002</option>
<option value="2001">2001</option>
<option value="2000">2000</option>
<option value="1999">1999</option>
<option value="1998">1998</option>
<option value="1997">1997</option>
<option value="1996">1996</option>
<option value="1995">1995</option>
<option value="1994">1994</option>
<option value="1993">1993</option>
<option value="1992">1992</option>
<option value="1991">1991</option>
<option value="1990">1990</option>
<option value="1989">1989</option>
<option value="1988">1988</option>
<option value="1987">1987</option>
<option value="1986">1986</option>
<option value="1985">1985</option>
<option value="1984">1984</option>
<option value="1983">1983</option>
<option value="1982">1982</option>
<option value="1981">1981</option>
<option value="1980">1980</option>
<option value="1979">1979</option>
<option value="1978">1978</option>
<option value="1977">1977</option>
<option value="1976">1976</option>
<option value="1975">1975</option>
<option value="1974">1974</option>
<option value="1973">1973</option>
<option value="1972">1972</option>
<option value="1971">1971</option>
<option value="1970">1970</option>
<option value="1969">1969</option>
<option value="1968">1968</option>
<option value="1967">1967</option>
<option value="1966">1966</option>
<option value="1965">1965</option>
<option value="1964">1964</option>
<option value="1963">1963</option>
<option value="1962">1962</option>
<option value="1961">1961</option>
<option value="1960">1960</option>
<option value="1959">1959</option>
<option value="1958">1958</option>
<option value="1957">1957</option>
<option value="1956">1956</option>
<option value="1955">1955</option>
<option value="1954">1954</option>
<option value="1953">1953</option>
<option value="1952">1952</option>
<option value="1951">1951</option>
<option value="1950">1950</option>
<option value="1949">1949</option>
<option value="1948">1948</option>
<option value="1947">1947</option>
<option value="1946">1946</option>
<option value="1945">1945</option>
<option value="1944">1944</option>
<option value="1943">1943</option>
<option value="1942">1942</option>
<option value="1941">1941</option>
<option value="1940">1940</option>
<option value="1939">1939</option>
<option value="1938">1938</option>
<option value="1937">1937</option>
<option value="1936">1936</option>
<option value="1935">1935</option>
<option value="1934">1934</option>
<option value="1933">1933</option>
<option value="1932">1932</option>
<option value="1931">1931</option>
<option value="1930">1930</option>
<option value="1929">1929</option>
<option value="1928">1928</option>
<option value="1927">1927</option>
<option value="1926">1926</option>
<option value="1925">1925</option>
<option value="1924">1924</option>
<option value="1923">1923</option>
<option value="1922">1922</option>
<option value="1921">1921</option>
<option value="1920">1920</option>
<option value="1919">1919</option>
<option value="1918">1918</option>
<option value="1917">1917</option>
<option value="1916">1916</option>
<option value="1915">1915</option>
<option value="1914">1914</option>
<option value="1913">1913</option>
<option value="1912">1912</option>
<option value="1911">1911</option>
<option value="1910">1910</option>
<option value="1909">1909</option>
<option value="1908">1908</option>
<option value="1907">1907</option>
<option value="1906">1906</option>
<option value="1905">1905</option>
<option value="1905">1904</option>
<option value="1905">1903</option>
<option value="1905">1902</option>
<option value="1905">1901</option>
<option value="1905">1900</option>
</select>
</td>

    </tr>


    <tr>
        <td> <b> Nationality: </b></td>
        <td> <input type="text" name="nat" placeholder=""/> </td>
    </tr> 


    <tr>
        <td> <b> Business ID: </b></td>
        <td> <input type="text" name="bid" placeholder=""/> </td>
    </tr> 


    <tr>
        <td> <b> __________________________ </b> </td>
        <td> <b> __________________ </b> </td>
    </tr>
    <tr>
        <td> <b> *Addresses </b></td>
    </tr> 

    <tr>
        <td> <b> House No.: </b></td>
        <td> <input type="text" name="hno" placeholder=""/> </td>
    </tr> 

    <tr>
        <td> <b> Road No.: </b></td>
        <td> <input type="text" name="rno" placeholder=""/> </td>
    </tr> 

    <tr>
        <td> <b> Area Name: </b></td>
        <td> <input type="text" name="area" placeholder=""/> </td>
    </tr> 

    <tr>
        <td> <b> Area Code: </b></td>
        <td> <input type="text" name="acode" placeholder=""/> </td>
    </tr> 

    <tr>
        <td> <b> District: </b></td>
        <td> <input type="text" name="dis" placeholder=""/> </td>
    </tr> 

    <tr>
        <td> <b> Division: </b></td>
        <td> <input type="text" name="div" placeholder=""/> </td>
    </tr> 

    <tr>
        <td> <b> Country: </b></td>
        <td> <input type="text" name="country" placeholder=""/> </td>
    </tr> 

    <tr>
        <td> <b> Country Code: </b></td>
        <td> <input type="text" name="ccode" placeholder=""/> </td>
    </tr> 

    <tr>
        <td> <b> Time Zone: </b></td>
        <td> <input type="text" name="time" placeholder=""/> </td>
    </tr> 


    <tr>
        <td> <b> __________________________ </b> </td>
        <td> <b> __________________ </b> </td>
    </tr>
    <tr>
        <td> <b> *Contact Numbers </b> </td>
    </tr> 

    <tr>
        <td> <b> Office: </b> </td>
        <td> <input type="number" name="ophone" placeholder=""> </td> 
    </tr> 

    <tr>
        <td> <b> Outlet: </b> </td>
        <td> <input type="number" name="tphone" placeholder=""> </td> 
    </tr> 

    <tr>
        <td> <b> Mobile: </b> </td>
        <td> <input type="number" name="mphone" placeholder=""> </td> 
    </tr> 


    <tr>
        <td> <b> __________________________ </b> </td>
        <td> <b> __________________ </b> </td>
    </tr>
    <tr>
        <td> <b> Other Email Address [If Any] </b> </td>
    </tr> 

    <tr>
        <td> <b> Email Address: </b> </td>
        <td> <input type="text" name="email1" placeholder=""> </td> 
    </tr>

    <tr>
        <td> <b> Email Address: </b> </td>
        <td> <input type="text" name="email2" placeholder=""> </td> 
    </tr>

    <tr>
        <td> <b> Email Address: </b> </td>
        <td> <input type="text" name="email3" placeholder=""> </td> 
    </tr>

    <tr>
        <td> <b> __________________________ </b> </td>
        <td> <b> __________________ </b> </td>
    </tr>
    <tr>
        <td> <b> Other Websites [If Any] </b></td>
    </tr>

    <tr>
        <td> <b> Website: </b></td>
        <td> <input type="text" name="web1" placeholder=""/> </td>
    </tr>

    <tr>
        <td> <b> Website: </b></td>
        <td> <input type="text" name="web2" placeholder=""/> </td>
    </tr>

    <tr>
        <td> <b> Website: </b></td>
        <td> <input type="text" name="web3" placeholder=""/> </td>
    </tr>

    <tr>
        <td> <b> __________________________ </b> </td>
        <td> <b> __________________ </b> </td>
    </tr>
    <tr>
        <td> <b> Other Organizations [If Any] </b></td>
    </tr>

    <tr>
        <td> <b> Organization: </b></td>
        <td> <input type="text" name="org1" placeholder=""/> </td>
    </tr>

    <tr>
        <td> <b> Organization: </b></td>
        <td> <input type="text" name="org2" placeholder=""/> </td>
    </tr>

    <tr>
        <td> <b> Organization: </b></td>
        <td> <input type="text" name="org3" placeholder=""/> </td>
    </tr>   


    <tr>
        <td> <b> __________________________ </b> </td>
        <td> <b> __________________ </b> </td>
    </tr>
    <tr>
        <td> <b> Non-profit Businesses [If Any] </b></td>
    </tr>

    <tr>
        <td> <b> Business Name: </b></td>
        <td> <input type="text" name="non1" placeholder=""/> </td>
    </tr>

    <tr>
        <td> <b> Business Name: </b></td>
        <td> <input type="text" name="non2" placeholder=""/> </td>
    </tr>

    <tr>
        <td> <b> Business Name: </b></td>
        <td> <input type="text" name="non3" placeholder=""/> </td>
    </tr>



    <tr>
        <td> <b> __________________________ </b> </td>
        <td> <b> __________________ </b> </td>
    </tr>
    <tr>
        <td> <b> Preferred Currencies </b></td>
    </tr>   

    <tr>
        <td> <b> Currency: </b></td>
        <td> <input type="text" name="curr1" placeholder=""/> </td>
    </tr>

    <tr>
        <td> <b> Currency: </b></td>
        <td> <input type="text" name="curr2" placeholder=""/> </td>
    </tr>

    <tr>
        <td> <b> Currency: </b></td>
        <td> <input type="text" name="curr3" placeholder=""/> </td>
    </tr>



    <tr>
        <td> <b> __________________________ </b> </td>
        <td> <b> __________________ </b> </td>
    </tr>
    <tr>
        <td> <b> *Security Codes </b></td>
        <td>  [Must be Remembered] </td>
    </tr>

    <tr>
        <td> <b> Security Code 1: </b></td>
        <td> <input type="number" name="scode1" placeholder=""/> </td>
    </tr>

    <tr>
        <td> <b> Security Code 2: </b></td>
        <td> <input type="number" name="scode2" placeholder=""/> </td>
    </tr>

    <tr>
        <td> <b> Security Code 3: </b></td>
        <td> <input type="number" name="scode3" placeholder=""/> </td>
    </tr>   

    <tr>
        <td> <b> __________________________ </b> </td>
        <td> <b> __________________ </b> </td>
    </tr>

    <tr>
        <td> <b> Upload Image: </b> </td> 
        <td> <input type="file" name="strFile1" id="strFile1" /> </td> 
    </tr> 



    <tr>    
            <td> </td>
            <td> <input type="submit" value="Submit" name="submit"> </td>
    </tr>



    </table>
</form>
</html>

3 个答案:

答案 0 :(得分:5)

你插入错误的表格。表profile_company中有列phone_outlet,但是您要插入表profile_individual

答案 1 :(得分:0)

当您在INSERT语句的字段列表中指定的列名不存在于要插入数据的表中时,会导致出现此错误消息。

字段列表是INSERT语句的一部分,您可以在其中指定要在查询中提供的字段的顺序:

INSERT INTO tablename(column1, column2, column3) VALUES('data 1', 'data 2', 'data 3');
                      ^ this is the field list ^

可能这是由其中一个列名称的错误输入引起的,但除非您提供完整的错误消息,否则我们无法确定

比如说,你有一个名为Person的表:

Person
-----------
first_name VARCHAR(255)
last_name  VARCHAR(255)

使用此表,如果您尝试了以下SQL,则会得到Unknown column in field list 'frist_name'(请注意拼写错误):

INSERT INTO Person(frist_name, last_name) VALUES('Jeff', 'Atwood');
                   ^ This field doesn't exist in Person, but fIRst_name does!

您也正在插入profile_individual,但您没有包含它的架构。我假设它有一个,因为你没有得到一个表不存在,但没有它的模式你不能分辨哪个列在字段列表中输入不正确。

通过执行:

,您可以更加简洁地表达profile_individual
EXPLAIN profile_individual;

编辑:正如您所提到的,此错误引用了名为phone_outlet的列。这意味着phone_outlet不是profile_individual中的列。如果需要添加此列,请执行:

ALTER TABLE profile_individual ADD phone_outlet VARCHAR(255);

(只需用适当的数据类型代替VARCHAR(255)

但是,我注意到您的代码目前正在使用已弃用的 mysql_*系列函数,并且容易受到SQL注入攻击。如果切换到PDO,你可以一石二鸟。

另外,我注意到您的列名称中有一种模式:some_value_1some_value_2等。如果您提供的列数超过了列数,该怎么办?例如,如果一个人有超过3封电子邮件,该怎么办?更好的架构是将电子邮件的想法抽象到新表。这意味着,创建一个emails表,其中包含电子邮件地址列和另一个表(称为外键),该表将电子邮件链接到个人。

有关详情,请查看Database Relationships 101 on Nettuts

答案 2 :(得分:0)

也许你正在插入错误的表格。

您创建的表格为profile_company,但您的INSERT位于profile_individual