Jump to content

insert statement not working


jimfog

Recommended Posts

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

oh...... :happy0046:

Link to comment
Share on other sites

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...