douling6469 2014-06-18 13:35
浏览 97

错误:Champ'product_name'inconnu dans字段列表

I am trying to store form data in a database using WampServer.

When I click on the submit button it shows me this error:

"Error: Champ 'product_name' inconnu dans field list".

I am using the same work for another form. That form is working but i dont know what is wrong with this one, Please help me out

My form code is :

<form action="saddproduct.php" enctype="multipart/form-data" name="myForm" id="myForm" 
 method="post"> 
    <table width="90%" border="1" cellpadding="6">
        <tr>
            <td width="20%">Product Name</td>
            <td width="80%"> 
                <label> 
                <input name="product_name" type="text" id="product_name" size="60" /> 
            </label>    
            </td>
        </tr>
        <tr>
            <td width="20%">Product Code</td>
            <td width="80%"> 
                <label> 
                    <input name="product_code" type="text" id="product_code" size="60" /> 
                </label>    
            </td>
        </tr>
        <tr>
            <td width="20%">Product Availability</td>
            <td width="80%"> 
            <label>
                <select name="availability" id="availability">
                    <option value=""></option>
                    <option value="in"> In Stock </option>
                    <option value="out"> Out Of Stock </option>
                    </select>
                </label>    
            </td>
        </tr>
        <tr>
            <td width="20%">Product Price</td>
            <td width="80%">
            <label>
                Rs.
                <input name="price" type="text" id="price" size="12"  />
            </label>    
            </td>
         </tr>
         <tr>
             <td align="right">Category</td>
            <td>
        <label>
                <select name="category" id="category">
                    <option value=""></option>
                    <option value="living"> Living Rooms </option>
                    <option value="bed"> Bed Rooms </option>
                    <option value="dining"> Dining Rooms </option>
                    </select>
                </label>    
            </td>
        </tr>
        <tr>
            <td align="right">Sub category</td>
            <td>
                <label>
                    <select name="subcategory" id="subcategory">
                        <option value=""></option>
                        <option value="lsofa"> Lining Sofa </option>
                        <option value="lchair"> Living Chair </option>
                        <option value="ltable"> Living Table </option>
                        <option value="bking"> King Beds </option>
                        <option value="bqueen"> Queen Beds </option>
                        <option value="dtable"> Dining Tables </option>
                        <option value="dchairs"> Dining Chairs </option>
                        <option value="hsale"> Sale Item For Home Page </option>
                        <option value="psale"> Sale Item For Sale Page </option>
                    </select>
                </label>
            </td>
        </tr>
        <tr>
            <td width="20%">Product Detail</td>
            <td width="80%">
            <label>
                <textarea name="details" id="details" cols="64" rows="5"> </textarea>
            </label>    
            </td>
        </tr>

        <tr>
            <td>&nbsp;  </td>
            <td width="80%"> 
                <label> 
                    <input type="submit" name="button" id="button" class="button" value="Add This  
         Product Now"  />
                </label>    
            </td>
        </tr>
        <tr>
            <td width="20%">&nbsp;</td>
            <td width="80%">&nbsp;</td>
        </tr>
   </table>
</form>

And my processing PHP page is saddproduct.php which look like :

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


    // escape variables for security
    $product_name = mysqli_real_escape_string($con, $_POST['product_name']);
    $product_code = mysqli_real_escape_string($con, $_POST['product_code']);
    $availability = mysqli_real_escape_string($con, $_POST['availability']);

    $price = mysqli_real_escape_string($con, $_POST['price']);
    $category = mysqli_real_escape_string($con, $_POST['category']);
    $subcategory = mysqli_real_escape_string($con, $_POST['subcategory']);

    $details = mysqli_real_escape_string($con, $_POST['details']);


    $sql="INSERT INTO employee 
              (product_name , product_code, availability, price, 
               category, subcategory, details, date_added) 
          VALUES('$product_name','$product_code', '$availability',     
                '$price','$category','$subcategory','$details',now())" 
          or die (mysql_error());

    if (!mysqli_query($con,$sql)) {
      die('Error: ' . mysqli_error($con));
    }

    mysqli_close($con);
?>
  • 写回答

4条回答 默认 最新

  • dongsu2807 2014-06-18 13:41
    关注

    I am sure that if you verify your table structure you wont find any column named product_name, at least not with the exact case.

    Try verifying your column names, and if you still dont have a clue, try removing column names and sticking to the order of your table structure while putting NULL in fields with default content like auto increment and timestamps.

    评论

报告相同问题?

悬赏问题

  • ¥15 高缺失率数据如何选择填充方式
  • ¥50 potsgresql15备份问题
  • ¥15 Mac系统vs code使用phpstudy如何配置debug来调试php
  • ¥15 目前主流的音乐软件,像网易云音乐,QQ音乐他们的前端和后台部分是用的什么技术实现的?求解!
  • ¥60 pb数据库修改与连接
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!