Professional Web Applications Themes

New record not populating with default values - MySQL

Hi, I have a MySql table where the field supplier_code cannot be null and has a default value of 'NONE' In PHP I'm creating a new record with the code $query_new_stock = "INSERT into stock set part_id = '$part_id', part_num = '$part_num'"; I have tried $query_new_stock = "INSERT into stock set part_id = '$part_id'"; and $query_new_stock = "INSERT into stock (part_id) values ('$part_id')"; and $query_new_stock = "INSERT into stock set part_id = '$part_id', part_num = '$part_num', supplier_code = 'NONE'"; None of these give the field supplier_code as NONE TIA...

  1. #1

    Default New record not populating with default values

    Hi,

    I have a MySql table where the field supplier_code cannot be null and
    has a default value of 'NONE'

    In PHP I'm creating a new record with the code

    $query_new_stock = "INSERT into stock
    set part_id = '$part_id',
    part_num = '$part_num'";

    I have tried

    $query_new_stock = "INSERT into stock
    set part_id = '$part_id'";

    and

    $query_new_stock = "INSERT into stock (part_id)
    values ('$part_id')";

    and

    $query_new_stock = "INSERT into stock
    set part_id = '$part_id',
    part_num = '$part_num',
    supplier_code = 'NONE'";

    None of these give the field supplier_code as NONE

    TIA

    Robbo Guest

  2. #2

    Default Re: New record not populating with default values

    On 23 Jul, 13:06, Robbo <com> wrote: 

    Please post the "CREATE TABLE" schema from phpmyadmin

    Captain Guest

  3. #3

    Default Re: New record not populating with default values

    On Jul 23, 1:56 pm, Captain Paralytic <com> wrote: 











    >
    > Please post the "CREATE TABLE" schema from phpmyadmin- Hide quoted text -
    >
    > - Show quoted text -[/ref]

    As requested...


    -- phpMyAdmin SQL Dump
    -- version 2.10.1
    -- http://www.phpmyadmin.net
    --
    -- Host: localhost
    -- Generation Time: Jul 24, 2007 at 09:30 AM
    -- Server version: 4.0.0
    -- PHP Version: 4.2.3

    SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";

    --
    -- Database: `forest_client_FDS000003`
    --

    -- --------------------------------------------------------

    --
    -- Table structure for table `stock`
    --

    CREATE TABLE `stock` (
    `part_id` varchar(10) NOT NULL default '',
    `supplier_code` varchar(6) NOT NULL default 'NONE',
    `part_num` varchar(16) NOT NULL default '',
    `description` varchar(40) default NULL,
    `weight` float default NULL,
    `stock_type_code` char(2) NOT NULL default 's1',
    `qty_instock` float NOT NULL default '0',
    `qty_min` smallint(6) NOT NULL default '0',
    `qty_purchase` smallint(6) NOT NULL default '1',
    `retail_price` float NOT NULL default '0',
    `trade_price` float NOT NULL default '0',
    `cost_price` float NOT NULL default '0',
    `vat_code` char(2) NOT NULL default 'v0',
    `bin` varchar(7) default NULL,
    `base_price` float NOT NULL default '0',
    `rec_locked` set('0','1') NOT NULL default '0',
    `qty_sellin` smallint(6) NOT NULL default '1',
    `qty_allocated` smallint(6) default NULL,
    `web_price` float NOT NULL default '0',
    `rrp_price` float default NULL,
    `notes` longtext,
    `brand` varchar(20) default NULL,
    PRIMARY KEY (`part_id`),
    KEY `part_num` (`part_num`),
    KEY `retail_price` (`retail_price`),
    KEY `vat_code` (`vat_code`),
    KEY `rrp_price` (`rrp_price`),
    KEY `description` (`description`),
    KEY `qty_instock` (`qty_instock`),
    KEY `bin` (`bin`)
    ) TYPE=MyISAM;

    Robbo Guest

  4. #4

    Default Re: New record not populating with default values

    On 24 Jul, 09:33, Robbo <com> wrote: 
    > [/ref]
    > [/ref]
    > [/ref]
    > [/ref]
    > [/ref]
    > [/ref]
    > [/ref]
    > [/ref]
    > [/ref]
    > [/ref]
    > [/ref]
    > [/ref]


    >
    > As requested...
    >
    > -- phpMyAdmin SQL Dump
    > -- version 2.10.1
    > --http://www.phpmyadmin.net
    > --
    > -- Host: localhost
    > -- Generation Time: Jul 24, 2007 at 09:30 AM
    > -- Server version: 4.0.0
    > -- PHP Version: 4.2.3
    >
    > SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
    >
    > --
    > -- Database: `forest_client_FDS000003`
    > --
    >
    > -- --------------------------------------------------------
    >
    > --
    > -- Table structure for table `stock`
    > --
    >
    > CREATE TABLE `stock` (
    > `part_id` varchar(10) NOT NULL default '',
    > `supplier_code` varchar(6) NOT NULL default 'NONE',
    > `part_num` varchar(16) NOT NULL default '',
    > `description` varchar(40) default NULL,
    > `weight` float default NULL,
    > `stock_type_code` char(2) NOT NULL default 's1',
    > `qty_instock` float NOT NULL default '0',
    > `qty_min` smallint(6) NOT NULL default '0',
    > `qty_purchase` smallint(6) NOT NULL default '1',
    > `retail_price` float NOT NULL default '0',
    > `trade_price` float NOT NULL default '0',
    > `cost_price` float NOT NULL default '0',
    > `vat_code` char(2) NOT NULL default 'v0',
    > `bin` varchar(7) default NULL,
    > `base_price` float NOT NULL default '0',
    > `rec_locked` set('0','1') NOT NULL default '0',
    > `qty_sellin` smallint(6) NOT NULL default '1',
    > `qty_allocated` smallint(6) default NULL,
    > `web_price` float NOT NULL default '0',
    > `rrp_price` float default NULL,
    > `notes` longtext,
    > `brand` varchar(20) default NULL,
    > PRIMARY KEY (`part_id`),
    > KEY `part_num` (`part_num`),
    > KEY `retail_price` (`retail_price`),
    > KEY `vat_code` (`vat_code`),
    > KEY `rrp_price` (`rrp_price`),
    > KEY `description` (`description`),
    > KEY `qty_instock` (`qty_instock`),
    > KEY `bin` (`bin`)
    > ) TYPE=MyISAM;- Hide quoted text -
    >
    > - Show quoted text -[/ref]

    I just tried all of the queries that you supplied in phpmyadmin and
    all gave supplier_code = 'NONE'

    Captain Guest

Similar Threads

  1. Populating an array with a list of values
    By samb1 in forum Macromedia ColdFusion
    Replies: 3
    Last Post: February 21st, 02:45 PM
  2. Replies: 2
    Last Post: December 28th, 06:27 PM
  3. default values
    By Elias in forum Ruby
    Replies: 2
    Last Post: December 8th, 08:45 AM
  4. Populating field with value in previous record
    By Yair in forum Microsoft Access
    Replies: 4
    Last Post: September 18th, 08:16 PM

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
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139