INSERT INTO broken

Well since this is about INSERT I considered opening another thread for this one.
I have arrange an INSERT query as below. It is inserting ok except that the price field is being inserted in the lasname and lastname is not being inserted at all. Now I have checked the INSERT and the form I am sure there is not mistypes. So what is left is the table structure for the fields which I think where the problem is.


"INSERT INTO costumers
(firstname,lastname,birthdate,telephone,product_name,price,details,category,subcategory,city,state,zipcode, country)            
VALUES('$fname','$lname','$birthdate',' $telephone','$itemname','$price','$details','$category','$subcategory','$city','$state','$zipcode','$country')";


Table structure any advise.



--
-- Table structure for table `costumers`
--

CREATE TABLE IF NOT EXISTS `costumers` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `firstname` char(50) CHARACTER SET utf8 NOT NULL,
  `lastname` char(50) CHARACTER SET utf8 NOT NULL,
  `birthdate` date NOT NULL,
  `telephone` varchar(12) CHARACTER SET utf8 NOT NULL,
  `product_name` varchar(225) CHARACTER SET utf8 NOT NULL,
  `price` varchar(12) CHARACTER SET utf8 NOT NULL,
  `details` varchar(225) CHARACTER SET utf8 NOT NULL,
  `category` varchar(100) CHARACTER SET utf8 NOT NULL,
  `subcategory` varchar(100) CHARACTER SET utf8 NOT NULL,
  `City` varchar(50) CHARACTER SET utf8 NOT NULL,
  `state` varchar(50) CHARACTER SET ucs2 NOT NULL,
  `zipcode` varchar(10) CHARACTER SET utf8 NOT NULL,
  `Country` char(25) CHARACTER SET utf8 NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=7 ;


your INSERT query is just fine

you can confirm this by substituting actual values for your php variables, and running the query right in mysql, i.e. not via php

this means you should check to make sure you are assigning the php variable values properly

that’s probably where your problem is

:slight_smile:

There was some mistakes in the form, I was giving a different name in some of the form fields, that’s why there was not data recognized by the query statement.