MySQL insert problems

Namecheap AuctionsNamecheap Auctions
Namecheap AuctionsNamecheap Auctions
SpaceshipSpaceship
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
Close
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
Close
If ID is primary key, auto-increment, there is not need to supply a value for that field...
 
0
Close
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
Close
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
Close
DomainEasy: flexible LTO options. Close more domain deals with financing.

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Switch between accounts
You can now stay logged in to more than one NamePros account in the same browser. Click your avatar, then "Accounts in this browser", to...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back