Error: Champ 'product_name' inconnu dans field list
20,455
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.
Author by
user3694543
Updated on December 20, 2020Comments
-
user3694543 over 3 years
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> </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%"> </td> <td width="80%"> </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); ?>