Jump to content

Deatalis wont pass into database


mikebyrne

Recommended Posts

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");
}
}
?>

 

Link to comment
Share on other sites

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')";

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.