data NOT being inserted into SQL table
data NOT being inserted into SQL table
For some odd reason...the second line (the suck-o mug one) doesnt get added to the table.
http://code.suck-o.com/97
The above link is the relevant table. (I extracted the table and omitted the rest of the code which is working perfect to save your eyes.)
The curious thing is, the first value is entered, the second one isnt.
For the first link, I put the relevant line in @@ to make it easier to spot
http://code.suck-o.com/97
The above link is the relevant table. (I extracted the table and omitted the rest of the code which is working perfect to save your eyes.)
The curious thing is, the first value is entered, the second one isnt.
For the first link, I put the relevant line in @@ to make it easier to spot
- bad_brain
- Site Owner
- Posts: 11636
- Joined: 06 Apr 2005, 16:00
- 19
- Location: In your eye floaters.
- Contact:
hm, are you sure you don't have to use ` for the names?
I looked at one of my db dumps and it looks like this:
I looked at one of my db dumps and it looks like this:
Code: Select all
DROP TABLE IF EXISTS `test1`;
CREATE TABLE `test1` (
`id` int(11) NOT NULL auto_increment,
`name` varchar(100) NOT NULL default '',
`dedication` varchar(100) NOT NULL default '',
`body` text NOT NULL,
PRIMARY KEY (`id`)
)
- bad_brain
- Site Owner
- Posts: 11636
- Joined: 06 Apr 2005, 16:00
- 19
- Location: In your eye floaters.
- Contact:
um, what are those @ about in line 7? they don't appear in the mysql reference for INSERTs using VALUES:
Code: Select all
INSERT INTO tbl_name (a,b,c) VALUES(1,2,3),(4,5,6),(7,8,9);
- bad_brain
- Site Owner
- Posts: 11636
- Joined: 06 Apr 2005, 16:00
- 19
- Location: In your eye floaters.
- Contact:
hm, shouldn't you better declare the table columns like here:
http://code.suck-o.com/99
at least that's how it is shown in the reference...
edit: meh, nvm...should work without it as long as you give values to all columns...
http://code.suck-o.com/99
at least that's how it is shown in the reference...
edit: meh, nvm...should work without it as long as you give values to all columns...
Ok...so I went into mysql Adminstrator, dropped the table and ran the code again, with ALL the values added. It seems that the code is "run once", currently, it seems that I cannot update the values, I have to drop the table and then run the code again in order to be able to add any new values.
That is rather bothersome...is there some way to overcome this?
That is rather bothersome...is there some way to overcome this?
- bad_brain
- Site Owner
- Posts: 11636
- Joined: 06 Apr 2005, 16:00
- 19
- Location: In your eye floaters.
- Contact:
alrighty, works for me now, 2 errors:
- a typo in the "mug" query, check the comma in "c":
but that's not the main error.
- you have 5 columns:
product_id
product_name
product_description
product_price
product_quantity
but you try to submit 6 values in each query, remove the 6th value ('d') in both queries...
- a typo in the "mug" query, check the comma in "c":
Code: Select all
('00002', 'suck-o mug!', 'a','b','c,','d')
- you have 5 columns:
product_id
product_name
product_description
product_price
product_quantity
but you try to submit 6 values in each query, remove the 6th value ('d') in both queries...