Beginner: table insertion problems

Source: Internet
Author: User
[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') ";

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.