[Help for new users] table insertion problem $ query11 = & quot; selectlast_insert_id () & quot; $ result11 = mysql_query ($ query11 ); $ row = mysql_fetch_row ($ result1 [New user help] table insertion problem
$ Query11 = "select last_insert_id ()";
$ Result11 = mysql_query ($ query11 );
$ Row = mysql_fetch_row ($ result11 );
$ Id = $ row [0];
$ User = "xxx ";
$ Type = "yyy ";
$ Time = date ("Y-m-d H: I: s ");
Echo"
$ Id | $ user | $ type | $ time
";
/*
So far, the output is normal.
This is the output
41 | xxx | yyy | 14:56:43
*/
$ Query2 = "insert into finding values ($ id, $ user, $ type, $ time )";
$ Result2 = mysql_query ($ query2 );
After these two statements are executed, why can't the finding table be inserted,
If you can insert only strings, for example, $ query2 = "insert into finding values ($ id, 'XXX', 'yyy', '2017-00-00 00:00:00 ')";
After mysql_query ($ query2); no problem
For help!
This is the table structure
+ ------- + ------------- + ------ + ----- + --------- + ------- +
| Field | Type | Null | Key | Default | Extra |
+ ------- + ------------- + ------ + ----- + --------- + ------- +
| Id | int (8) | NO | PRI | NULL |
| User | varchar (4) | NO | NULL |
| Type | varchar (40) | NO | NULL |
| Time | datetime | NO | NULL |
+ ------- + ------------- + ------ + ----- + --------- + ------- +
------ Solution --------------------
Values ($ id, '$ user',' $ type', '$ time') ";