This is a discussion on New record not populating with default values within the MySQL Database forums, part of the Database Forums category; Hi, I have a MySql table where the field supplier_code cannot be null and has a default value of 'NONE' ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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 |
|
|||
|
On 23 Jul, 13:06, Robbo <i...@fds7.com> wrote:
> 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 Please post the "CREATE TABLE" schema from phpmyadmin |
|
|||
|
On Jul 23, 1:56 pm, Captain Paralytic <paul_laut...@yahoo.com> wrote:
> On 23 Jul, 13:06, Robbo <i...@fds7.com> wrote: > > > > > > > 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 > > Please post the "CREATE TABLE" schema from phpmyadmin- Hide quoted text - > > - Show quoted text - 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; |
|
|||
|
On 24 Jul, 09:33, Robbo <i...@fds7.com> wrote:
> On Jul 23, 1:56 pm, Captain Paralytic <paul_laut...@yahoo.com> wrote: > > > > > > > On 23 Jul, 13:06, Robbo <i...@fds7.com> wrote: > > > > 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 > > > Please post the "CREATE TABLE" schema from phpmyadmin- Hide quoted text - > > > - Show quoted text - > > 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 - I just tried all of the queries that you supplied in phpmyadmin and all gave supplier_code = 'NONE' |