-1

这是我在 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>
4

3 回答 3

5

您正在插入错误的表。您在表 profile_company 中有列phone_outlet,但您在表 profile_individual 中插入

于 2013-06-27T12:48:50.073 回答
0

This error message is caused when a column name which you specify in an INSERT statement's field list does not exist in the table into which you are inserting data.

The field list is the part of the INSERT statement where you specify the order of the fields you are providing in the query:

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

Likely this is caused by a mistyping of one of the column names, but we can't know for sure unless you provide the full error message

Say, for example you had a table called Person:

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

With this table, if you attempted the following SQL you would get Unknown column in field list 'frist_name' (Notice the typo):

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

You also are inserting into profile_individual, but you didn't include it's schema. I assume it has one since you're not getting a table does not exists, but without its schema you can't tell which column is typed incorrectly in the field list.

You can get a more concise representation of profile_individual by executing:

EXPLAIN profile_individual;

EDIT: As you mention this error references a column named phone_outlet. This means that phone_outlet is not a column in profile_individual. If you need to add this column, execute:

ALTER TABLE profile_individual ADD phone_outlet VARCHAR(255);

(Just substitue the proper datatype in place of VARCHAR(255))

However, I notice that your code is currently using the deprecated mysql_* family of functions and is vulnerable to SQL injection attacks. You can get two birds with one stone if you switch to PDO.

Also, I notice a pattern in your column names: some_value_1, some_value_2, etc. What if there are more than the number of columns which you provide. For example, what if an individual has more than 3 emails. A better schema for this is to abstract the idea of an email to a new table. That means, creating an emails table which has a column for the email address and another (called a foreign key), which links the email to the individual.

For more on this, check out Database Relationships 101 on Nettuts.

于 2013-06-27T12:52:56.420 回答
0

Maybe you're inserting into the wrong table.

The table you created is profile_company, but your INSERT is on profile_individual.

于 2013-06-27T12:52:56.800 回答