Dynadot โ€” .com Registration $8.99

MySQL insert problems

Spaceship Spaceship
Watch

paaaaaaaaaa

Established Member
Impact
6
Im having some problems with mySQL,

Ive been trying to INSERT a new record I know you have to do it like:
PHP:
INSERT INTO artists (id, name, date, location)
VALUES ('', '$name', '$date', '$location')
This is the code im useing but an example, it normally works for me but not this time. So to do some debugging I made phpmyadmin pump out some php for an insert and it adds in two extra values like:
PHP:
INSERT INTO artists (id, name, date, location)
VALUES ('', '$name', '$date', '','', NULL)
This works but when I tell the last value to be a variable the extra values move about so I just cant get it right. Anybody know whats going on here?
 
Last edited:
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
if id is primary key, auto-increment, change '' to NULL.
 
0
•••
If ID is primary key, auto-increment, there is not need to supply a value for that field...
 
0
•••
sdsinc said:
If ID is primary key, auto-increment, there is not need to supply a value for that field...

You took my words! :P :tu:
 
0
•••
This should be the correct, and working code:
Code:
INSERT INTO `artists` (id, name, date, location) VALUES ('','$name','$date','$location');

paaaaaaaaaa, where you been?
 
1
•••
Appraise.net
Unstoppable Domains
Domain Recover
DomainEasy โ€” Live Options
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back