简体   繁体   中英

Can mssql_query detect inserting error?

I am trying to detect inserting result.

When I tried to insert with INSERT INTO table (1,2,'t') this will result in inserting error because of the third column of my table is decimal type,but mssql_query will return true.

but when I tested with INSET INTO table (1,2,'t') this will return false,like it should.

Why the first statement returning true? and how can we check that it is an error not true!!

Correct syntax is:

insert into table_name (column_name1, column_name2, ..) 
VALUES (value_of_column1, value_of_column2, ..)

As you already know ordering part is not required, but i highly suggest you to do ordering first and then give values to it.

mysql_query return false on error and you can get error by using mysql_error function.

And keep this in your mind that you should surround values by quotations only when you are filling columns with type of varchar/char/date/datetime..

Other types like boolean, int, decimal and.. should be provided without quotations.

Hope it solve your problem;)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM