I’m working on inserting to a database where all fields are NOT NULL (3rd party script).
here is a snippet of the structure dump.
CREATE TABLE node
(
id
int(11) NOT NULL auto_increment,
time
varchar(20) NOT NULL COMMENT ‘Time of last checkin from the node’,
netid
int(11) NOT NULL,
name
varchar(100) NOT NULL COMMENT ‘node’‘s name’, …
When I look at the database the value for time is empty.
INSERT INTO
node
(id
,time
,netid
,name
,description
,latitude
,longitude
,owner_name
,owner_email
,owner_phone
,owner_address
,approval_status
,ip
,mac
,robin
,batman
,memfree
,ssid
,pssid
,users
,kbup
,kbdown
,gateway
,gw-qual
,NTR
,routes
,hops
,RTT
,nbs
,rank
,top_users
,uptime
,nodes
,rssi
,rssi_hist
,rtt_hist
,ntr_hist
,usr_hist
,nkbd_hist
,nkbu_hist
,gateway_bit
,memlow
,usershi
) VALUES
(173, ‘’, 465, ‘Rivait Gateway 1’, ‘EOC 2610’, ‘42.30983128397199’, ‘-82.46515989303589’, ‘’, ‘info@lightwaveinternet.net’, ‘’, ‘’, ‘A’, ‘’, ‘00:02:6F:64:E0:6D’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, 0, ‘’, ‘’),
(174, ‘’, 465, ‘Harris’, ‘EOC 2610’, ‘42.315258002925006’, ‘-82.46131896972656’, ‘’, ‘info@lightwaveinternet.net’, ‘’, ‘’, ‘A’, ‘’, ‘00:02:6F:66:A4:59’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, 0, ‘’, ‘’),
(238, ‘’, 491, ‘mccoun-mini’, ‘Accton mini’, ‘36.81393597755405’, ‘-121.70515894889832’, ‘’, ‘’, ‘’, ‘’, ‘A’, ‘’, ‘00:12:CF:A4:A2:A4’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, 0, ‘’, ‘’),
(252, ‘’, 509, ‘Summit_West’, ‘WRT54GL’, ‘44.06217968592229’, ‘-121.35377883911133’, ‘’, ‘’, ‘’, ‘’, ‘A’, ‘’, ‘00:1D:7E:BB:A1:CA’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’, 0, ‘’, ‘’),
Notice all of the empty values.
The query they have to initially populate the database has only 11 fields, the values are in another array.
$fields = array(‘mac’,‘netid’,‘name’,‘description’,‘latitude’,‘longitude’,‘approval_status’,‘owner_name’,‘owner_email’,‘owner_phone’,‘owner_address’);
The query
$query = “INSERT INTO node”;
$query .= " (“.implode(”,“,$fields).”) “;
$query .= “VALUES('”.implode(”‘,’“,$values).”')";
mysql_query($query, $conn) or die("Error: Could not create node: ".mysql_error($conn));
I am writing some additional code and when I try to update those same 11 fields i get the error that the value for time is not set.
My question is why would their query work and mine kicks out the error?
Thanks for looking.
BTW, when did the forum get the face lift?
I had to put this all in one code block or the text all disappeared when I posted.