New record not populating with default values

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' ...


Go Back   Usenet Forums > Database Forums > MySQL Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 07-23-2007
Robbo
 
Posts: n/a
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

Reply With Quote
  #2 (permalink)  
Old 07-23-2007
Captain Paralytic
 
Posts: n/a
Default Re: New record not populating with default values

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

Reply With Quote
  #3 (permalink)  
Old 07-24-2007
Robbo
 
Posts: n/a
Default Re: New record not populating with default values

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;

Reply With Quote
  #4 (permalink)  
Old 07-24-2007
Captain Paralytic
 
Posts: n/a
Default Re: New record not populating with default values

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'

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 07:04 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0