mikebyrne Posted March 25, 2008 Share Posted March 25, 2008 Once the validation process is complete I want all my details to pass into my product table but Im getting the error: CDlklklklklklkk77koojoioiououooo90INSERT INTO product (Producttype, ProductName,Stockamount,Display, Description,Price, Display, Image, Image2) VALUES ('CD','lklklklklklkk','77','YES' 'koojoioiououooo', '90', '', '')Column count doesn't match value count at row 1 With Query INSERT INTO product (Producttype, ProductName,Stockamount,Display, Description,Price, Display, Image, Image2) VALUES ('CD','lklklklklklkk','77','YES' 'koojoioiououooo', '90', '', '') The code Im using is <?PHP require_once("adminconnect.php"); $ProductName = mysql_real_escape_string(trim($_POST['ProductName'])); $Description = mysql_real_escape_string(trim($_POST['Description'])); $Price = mysql_real_escape_string(trim($_POST['Price'])); $Stockamount = mysql_real_escape_string(trim($_POST['Stockamount'])); $Type = $_POST['Type']; $Display = strtoupper($_POST['display']); $Image = $_POST['Image']; $Image2 = $_POST['Image2']; $tbl_name="product"; if($_POST["action"] == "Add"){ $valid=1; if ($_POST['Type'] =="") { $valid=0; $style_name = "background-color:#FF5959"; $error_type = "Please enter the product type<br>"; } if ($_POST['ProductName']=="") { $valid=0; $style_name = "background-color:#FF5959"; $error_name = "The Product Name seems to be mising?<br>"; } if ($_POST['Description']=="") { $valid=0; $style_name = "background-color:#FF5959"; $error_description = "Your description seems to be mising?<br>"; } if ($_POST['Stockamount']=="") { $valid=0; $style_name = "background-color:#FF5959"; $error_amount = "Please enter the ammount of stock recivied<br>"; } if(empty($_POST['Price'])) { $valid=0; $style_name = "background-color:#FF5959"; $error_price = "Please enter the price<br>"; } if(preg_match("/\A[0-9]{1,16}(\.[0-9]{2}){0,1}$/",$_POST['Price']) != 1) { $valid = 0; $style_name = "background-color:#FF5959"; $error_price = 'Price is invalid. Numbers only (eg: 123.05)'; } if(empty($_POST['Stockamount'])) { $valid=0; $style_name = "background-color:#FF5959"; $error_amount = "Please enter a stock ammount<br>"; } if(preg_match("/\A[0-9]{1,16}(\.[0-9]{2}){0,1}$/",$_POST['Stockamount']) != 1) { $valid = 0; $style_name = "background-color:#FF5959"; $error_amount = 'Ammonut is invalid. Numbers only (eg: 1,2,3)'; } if ($valid==1) { $sql="INSERT INTO $tbl_name (Producttype, ProductName,Stockamount,Display, Description,Price, Display, Image, Image2) VALUES ('$Type','$ProductName','$Stockamount','$Display' '$Description', '$Price', '$Image', '$Image2')"; echo $_POST['Type']; echo $_POST['ProductName']; echo $_POST['Stockamount']; echo $_POST['Display']; echo $_POST['Description']; echo $_POST['Price']; echo $_POST['Image']; echo $_POST['Image2']; echo $sql; $result=mysql_query($sql)or die(mysql_error()."<p>With Query<br>$sql"); } } ?> Quote Link to comment Share on other sites More sharing options...
rhodesa Posted March 25, 2008 Share Posted March 25, 2008 There are a 2 problems. First, you are missing a comma between $Display and $Description Also, you don't have a value for Display $sql="INSERT INTO $tbl_name (Producttype, ProductName,Stockamount,Display, Description,Price, Display, Image, Image2) VALUES ('$Type','$ProductName','$Stockamount','$Display', '$Description', '$Price', 'MISSING DISPLAY HERE', '$Image', '$Image2')"; Quote Link to comment Share on other sites More sharing options...
mikebyrne Posted March 25, 2008 Author Share Posted March 25, 2008 Thanks, now just to figure out my uploading pictures problem and im done!!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.