SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Wizard co.ador's Avatar
    Join Date
    Apr 2009
    Posts
    1,054
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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.

    PHP Code:
    "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.
    Code:
    --
    -- 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 ;

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,016
    Mentioned
    53 Post(s)
    Tagged
    2 Thread(s)
    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

    r937.com | rudy.ca | Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Wizard co.ador's Avatar
    Join Date
    Apr 2009
    Posts
    1,054
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •