jimfog Posted September 17, 2012 Share Posted September 17, 2012 Here is a function that contains an insert statement, which statement does not achieve inserting the data into the db table: function uniqid_to_db($uniqid) { $conn = db_connect(); $result = $conn->query("insert into session [(randnumber)] values values($uniqid)");} Do you see anything wrong abobe? Randnumber, is the second column in the session table.I have tried various syntax combination but with no result. Link to comment Share on other sites More sharing options...
JamesB Posted September 17, 2012 Share Posted September 17, 2012 you've got 'values' repeated twice, also try removing the square brackets. Link to comment Share on other sites More sharing options...
jimfog Posted September 17, 2012 Author Share Posted September 17, 2012 oh...... Link to comment Share on other sites More sharing options...
jimfog Posted September 24, 2012 Author Share Posted September 24, 2012 this is the new statement-correct I think: INSERT INTO session(randnumber) VALUES ('gg'); Randnumber is the second column of a table, in which the first one is called timestamp.I run the above statement at phpMyadmin and I got the following message: #1364 - Field 'timestamp' doesn't have a default value the gg above is just for testing, despite I target the the Randnumber column, I get a message that refers to the timestamp column.Both columns are of the varchar type. WHat is wrong here? Link to comment Share on other sites More sharing options...
thescientist Posted September 24, 2012 Share Posted September 24, 2012 you're creating a new record in the DB. It seems like you didn't allow for timestamp to not have a (default) value if you aren't going to provide one on INSERT. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.